Skip to content

Commit

Permalink
PlanReleaseDate updated with Course Name
Browse files Browse the repository at this point in the history
  • Loading branch information
tuehoang committed Jun 22, 2022
1 parent 9d07705 commit ed8580f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 1 addition & 6 deletions compair/api/assignment_search_enddate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion compair/static/script-assignment-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function hideloadersearch() {
function showsearchapi(search_data) {

let tab = `<tr>
<th>Course Name</th>
<th>Assignment Name</th>
<th>Answering Begins</th>
<th>Answering Ends</th>
Expand All @@ -50,7 +51,7 @@ function showsearchapi(search_data) {
for (let key in search_data) {
//tab += `<tr><td colspan="4">${search_data[key]}</td></tr>`;
let obj = JSON.parse(search_data[key])
tab += `<tr><td>${JSON.stringify(obj.name).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.answer_start).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.answer_end).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.compare_start).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.compare_end).replace(/\"/g, "")}</td></tr>`;
tab += `<tr><td>${JSON.stringify(obj.course_name).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.name).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.answer_start).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.answer_end).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.compare_start).replace(/\"/g, "")}</td><td>${JSON.stringify(obj.compare_end).replace(/\"/g, "")}</td></tr>`;
iKey++;
}

Expand Down

0 comments on commit ed8580f

Please sign in to comment.