From ed8580fc735523e203ad8b2593ee7377cbb6a145 Mon Sep 17 00:00:00 2001 From: TueHoang Date: Wed, 22 Jun 2022 09:18:35 -0700 Subject: [PATCH] PlanReleaseDate updated with Course Name --- compair/api/assignment_search_enddate.py | 7 +------ compair/static/script-assignment-search.js | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/compair/api/assignment_search_enddate.py b/compair/api/assignment_search_enddate.py index 48c4f9509..e571533d4 100644 --- a/compair/api/assignment_search_enddate.py +++ b/compair/api/assignment_search_enddate.py @@ -60,13 +60,8 @@ def get(self): db_url = str(current_app.config['SQLALCHEMY_DATABASE_URI']) engine = create_engine(db_url, pool_size=5, pool_recycle=3600) conn = engine.connect() - ##sql_text = str("SELECT JSON_OBJECT('uuid', uuid,'name', name,'compare_start', compare_start, 'compare_end', compare_end) FROM assignment;"); - ##sql_text = str("SELECT JSON_OBJECT('uuid', uuid,'name', name,'compare_start', compare_start, 'compare_end', compare_end) FROM assignment WHERE compare_end >= '" + end_date + "';"); - ##sql_text = str("SELECT JSON_OBJECT('uuid', uuid,'name', name,'answer_start', answer_start,'answer_end', answer_end,'compare_start', compare_start, 'compare_end', compare_end) FROM assignment WHERE compare_end >= '" + end_date + "' OR answer_end >= '" + end_date + "';"); - sql_text = str("SELECT JSON_OBJECT('uuid', uuid,'name', name,'answer_start', date_format(answer_start, '%%M %%d, %%Y'),'answer_end', date_format(answer_end, '%%M %%d, %%Y'),'compare_start', date_format(compare_start, '%%M %%d, %%Y'), 'compare_end', date_format(compare_end, '%%M %%d, %%Y')) FROM assignment WHERE compare_end >= '" + end_date + "' OR answer_end >= '" + end_date + "';"); - + sql_text = str("SELECT JSON_OBJECT('course_name', t1.name,'name', t2.name,'answer_start', date_format(t2.answer_start, '%%M %%d, %%Y'),'answer_end', date_format(t2.answer_end, '%%M %%d, %%Y'),'compare_start', date_format(t2.compare_start, '%%M %%d, %%Y'), 'compare_end', date_format(t2.compare_end, '%%M %%d, %%Y')) FROM course as t1, assignment as t2 WHERE (t1.id = t2.course_id) AND (t2.compare_end >= '" + end_date + "' OR answer_end >= '" + end_date + "');"); ##print(sql_text) - result = conn.execute(sql_text) final_result = [list(i) for i in result] diff --git a/compair/static/script-assignment-search.js b/compair/static/script-assignment-search.js index 8b06fd6a8..7e66747c4 100644 --- a/compair/static/script-assignment-search.js +++ b/compair/static/script-assignment-search.js @@ -38,6 +38,7 @@ function hideloadersearch() { function showsearchapi(search_data) { let tab = ` + Course Name Assignment Name Answering Begins Answering Ends @@ -50,7 +51,7 @@ function showsearchapi(search_data) { for (let key in search_data) { //tab += `${search_data[key]}`; let obj = JSON.parse(search_data[key]) - tab += `${JSON.stringify(obj.name).replace(/\"/g, "")}${JSON.stringify(obj.answer_start).replace(/\"/g, "")}${JSON.stringify(obj.answer_end).replace(/\"/g, "")}${JSON.stringify(obj.compare_start).replace(/\"/g, "")}${JSON.stringify(obj.compare_end).replace(/\"/g, "")}`; + tab += `${JSON.stringify(obj.course_name).replace(/\"/g, "")}${JSON.stringify(obj.name).replace(/\"/g, "")}${JSON.stringify(obj.answer_start).replace(/\"/g, "")}${JSON.stringify(obj.answer_end).replace(/\"/g, "")}${JSON.stringify(obj.compare_start).replace(/\"/g, "")}${JSON.stringify(obj.compare_end).replace(/\"/g, "")}`; iKey++; }