Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/web.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added __pycache__/code.cpython-39.pyc
Binary file not shown.
111 changes: 111 additions & 0 deletions code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
from flask import Flask
from flask import render_template
from flask import Response
import sqlite3
import random
import io
import pandas as pd
from collections import Counter
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

app = Flask(__name__)


@app.route("/")
def cv_index():
cvs = get_cv()
res = ""
for i, cv in enumerate(cvs):
res += f"<h1>{i + 1})</h1>"
res += f"<p>Желаемая зарплата: {cv['salary']}.</p>"
res += f"<p>Образование: {cv['educationType']}.</p>"

return res


@app.route("/dashboard")
def dashboard():
con = sqlite3.connect('works.sqlite')
res = con.execute('SELECT SUBSTR(dateModify, 1, 4), COUNT(*) FROM works WHERE dateModify NOT NULL GROUP BY '
'SUBSTR(dateModify, 1, 4)').fetchall()
con.close()
return render_template('d2.html',
cvs=get_cv(),
labels=[row[0] for row in res],
data=[row[1] for row in res]
)


@app.route("/statistic")
def statistic():
jobTitles = get_list_field('jobTitle')
qualifications = get_list_field('qualification')
res = ""
csv = get_cv()
count = count_people_field1_not_match_field2(jobTitles, qualifications)
res += f"<p>Из {count[1]} людей не совпадают профессия и должность у {count[0]}</p>"

return res


def get_list_field(field):
con = sqlite3.connect('works.sqlite')
res = list(con.execute(f'select {field} from works'))
con.close()
return res


def dict_factory(cursor, row):
# обертка для преобразования
# полученной строки. (взята из документации)
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d


def get_cv():
con = sqlite3.connect('works.sqlite')
con.row_factory = dict_factory
res = list(con.execute('select * from works limit 20'))
con.close()
return res


@app.route('/plot.png')
def plot_png():
fig = create_figure()
output = io.BytesIO()
FigureCanvas(fig).print_png(output)
return Response(output.getvalue(), mimetype='image/png')


def create_figure():
fig = Figure()
axis = fig.add_subplot(1, 1, 1)
xs = range(100)
ys = [random.randint(1, 50) for x in xs]
axis.plot(xs, ys)
return fig


def count_people_field1_not_match_field2(field1, field2):
res_count = 0
total = 0
for (f1, f2) in zip(field1, field2):
total += 1
if not find_match(f1[0], f2[0]) and not find_match(f2[0], f1[0]):
res_count += 1
return res_count, total


def find_match(f1, f2):
arr1 = str(f1).lower().replace('-', ' ').split()
for word in arr1:
if word in str(f2).lower():
return True
return False


app.run()
32,684 changes: 32,684 additions & 0 deletions works.sqlite

Large diffs are not rendered by default.