diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/main.py b/.idea/main.py new file mode 100644 index 0000000..9d011bd --- /dev/null +++ b/.idea/main.py @@ -0,0 +1,116 @@ +import io +import random +import sqlite3 +import pandas as pd + +from flask import Flask +from flask import Response +from collections import Counter +from flask import render_template +from matplotlib.figure import Figure +from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas + +application = Flask(__name__) + +@application.route("/") +def index_cv(): + cvs = get_cv() + result = "" + for i, cv in enumerate(cvs): + result += f"

{i + 1})

" + result += f"

Желаемая зарплата: {cv['salary']}.

" + result += f"

Образование: {cv['educationType']}.

" + return result + +@application.route("/dashboard") +def dashboard(): + connected = sqlite3.connect('works.sqlite') + result = connected.execute('SELECT SUBSTR(dateModify, 1, 4), COUNT(*) FROM works WHERE dateModify NOT NULL GROUP BY ' + 'SUBSTR(dateModify, 1, 4)').fetchall() + connected.close() + return render_template('d2.html', + cvs = get_cv(), + labels = [row[0] for row in result], + data = [row[1] for row in result]) + +@app.route("/statistic") +def statistic(): + jobTitles = get_list_field('jobTitle') + qualifications = get_list_field('qualification') + result = "" + peop_count = count_people_field1_not_match_field2(jobTitles, qualifications) + res += f"

Из {peop_count[1]} людей не совпадают профессия и должность у {peop_count[0]}

" + res += f"

Топ 5 образований людей, которые работают менеджерами:

" + res += get_top(5, jobTitles, qualifications, "менеджер") + res += f"

Топ 5 должностей людей, которые по диплому являются инженерами:

" + res += get_top(5, qualifications, jobTitles, "инженер") + return result + +def get_top(top_size, field_to_search, field_to_return, str_to_search): + result = '' + full_top = top(field_to_search, field_to_return, str_to_search) + for i in range(top_size): + result += f"

- {full_top[i][0]} - {full_top[i][1]} чел.

" + return result + + +def get_list_field(field): + connected = sqlite3.connect('works.sqlite') + result = list(connected.execute(f'select {field} from works')) + connected.close() + return result + +def factor_dict(cursor, row): + d = {} + for index, col in enumerate(cursor.description): + d[col[0]] = row[index] + return d + +def get_cv(): + connected = sqlite3.connect('works.sqlite') + connected.row_factory = factor_dict + result = list(connected.execute('select * from works limit 20')) + connected.close() + return result + +@application.route('/plot.png') +def plot_png(): + figur = create_figure() + output = io.BytesIO() + FigureCanvas(figur).print_png(output) + return Response(output.getvalue(), mimetype='image/png') + +def create_figure(): + figur = Figure() + axis = figur.add_subplot(1, 1, 1) + xs = range(100) + ys = [random.randint(1, 50) for x in xs] + axis.plot(xs, ys) + return figur + +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 + +def top(f_to_search, f_to_return, str_to_search): + result = [] + for (f_s, f_r) in zip(f_to_search, f_to_return): + if str(f_s[0]).lower().find(str_to_search[:-2]) != -1: + if str(f_r[0]).find('None') == -1: + result.append(f_r[0]) + + return Counter(result).most_common() + +application.run() \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f589ca3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/web.iml b/.idea/web.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/web.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/works.sqlite b/.idea/works.sqlite new file mode 100644 index 0000000..efc4706 --- /dev/null +++ b/.idea/works.sqlite @@ -0,0 +1,7 @@ +SELECT * FROM 'education' LIMIT 0,30 + +SELECT * FROM 'genders' LIMIT 0,30 + +SELECT * FROM 'genders' LIMIT 0,30 + +SELECT * FROM 'works' LIMIT 0,30 \ No newline at end of file diff --git a/templates/htm.html b/templates/htm.html new file mode 100644 index 0000000..57be123 --- /dev/null +++ b/templates/htm.html @@ -0,0 +1,209 @@ + + + + + + + + + Dashboard Template · Bootstrap v5.1 + + + + + + + + + + + + + + + + + +
+
+ +
+
+

Dashboard

+
+
+ + +
+ +
+
+ +

Резюме

+
+ + + + + + + + + + + {% for cv in cvs %} + + + + + + + {% endfor %} + +
#ЗарплатаОбразованиеПол
{{ loop.index }}{{ cv.salary }}{{ cv.educationType }}{{ cv.gender }}
+
+
+
+
+ + + + + \ No newline at end of file