From 41caa25d44ffa579188e25406f26c6d2c53a31a0 Mon Sep 17 00:00:00 2001
From: CyberMagic404 <81950751+CyberMagic404@users.noreply.github.com>
Date: Sun, 26 Dec 2021 14:52:55 +0500
Subject: [PATCH 1/2] =?UTF-8?q?=D0=92=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?=
=?UTF-8?q?=D0=BD=D0=BE=201=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/.gitignore | 8 +++
.idea/.name | 1 +
.../inspectionProfiles/profiles_settings.xml | 6 ++
.idea/misc.xml | 7 ++
.idea/modules.xml | 8 +++
.idea/vcs.xml | 6 ++
Flask_task.py | 69 +++++++++++++++++++
works.sqlite | 0
8 files changed, 105 insertions(+)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/.name
create mode 100644 .idea/inspectionProfiles/profiles_settings.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 Flask_task.py
create mode 100644 works.sqlite
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..94f33bf
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+
+# IntellijIdea files
+*.iml
+.idea
+out
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..a055837
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+Flask_task.py
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
Желаемая зарплата: {cv['salary']}.
" + res += f"Образование: {cv['educationType']}.
" + + 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]) + + +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 + + +app.run() \ No newline at end of file diff --git a/works.sqlite b/works.sqlite new file mode 100644 index 0000000..e69de29 From ef73269f8ffd334175d81c8f1842806711e8ec29 Mon Sep 17 00:00:00 2001 From: CyberMagic404 <81950751+CyberMagic404@users.noreply.github.com> Date: Sun, 26 Dec 2021 15:15:47 +0500 Subject: [PATCH 2/2] =?UTF-8?q?=D0=92=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=202=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Flask_task.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Flask_task.py b/Flask_task.py index 94b2806..3193ba6 100644 --- a/Flask_task.py +++ b/Flask_task.py @@ -10,6 +10,22 @@ app = Flask(__name__) +def count_people_diploma_not_match_job(jobTitles, qualification): + result = 0 + total = 0 + for (jt, q) in zip(jobTitles, qualification): + total += 1 + if not does_diploma_match(jt[0], q[0]) and not does_diploma_match(q[0], jt[0]): + result += 1 + return result, total + + +def does_diploma_match(str1, str2): + str_array = str1.lower().replace('-', ' ').split() + for word in str_array: + if word in str2.lower(): + return True + return False @app.route("/") def cv_index(): @@ -31,6 +47,22 @@ def dashboard(): 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('jobTitle') + qualifications = get_list('qualification') + res = "" + count = count_people_diploma_not_match_job(jobTitles, qualifications) + res += f"Из {count[1]} людей не совпадают профессия и должность у {count[0]}
" + return res + + +def get_list(field): + con = sqlite3.connect('works.sqlite') + res = list(con.execute(f'select {field} from works')) + con.close() + return res + def dict_factory(cursor, row): # обертка для преобразования