From 69c617005d6f2e27cc6d00c15130fb0de6fa4f30 Mon Sep 17 00:00:00 2001 From: Kento HASEGAWA Date: Tue, 27 Aug 2019 02:44:19 +0900 Subject: [PATCH] Improve refresh method of the problem status view --- main.py | 30 +++++---------- roles/host.py | 3 +- static/js/adc2019.js | 21 ++++++----- templates/part_problem_status.html | 13 +------ templates/part_problem_status_list.html | 49 +++++++++++++++++++++++++ templates/part_request_status.html | 12 ------ 6 files changed, 72 insertions(+), 56 deletions(-) create mode 100644 templates/part_problem_status_list.html delete mode 100644 templates/part_request_status.html diff --git a/main.py b/main.py index 8d0c4ae..b2df00b 100644 --- a/main.py +++ b/main.py @@ -44,11 +44,17 @@ def webui_part_solver_status(): else: return abort(404) -@webui.route('/part/request/') -def webui_part_request_status(problem_name=None): +# @webui.route('/part/request/') +@webui.route('/part/problem_status/') +def webui_part_problem_status_list(problem_name=None): if (adc2019system.role is not None) and (adc2019system.role.type == 'host'): + problem = adc2019system.role.get_problem(problem_name) + solutions = reversed(sorted(problem.get_solutions().items(), key=lambda x:x[1].timestamp)) request_status = adc2019system.role.get_request_by_problem(problem_name) - return render_template('part_request_status.html', status=request_status) + if problem is None: + return abort(404) + else: + return render_template('part_problem_status_list.html', problem=problem, solutions=solutions, status=request_status) else: return abort(404) @@ -61,31 +67,13 @@ def webui_part_problem_status(name=None): if (adc2019system.role is not None) and (adc2019system.role.type == 'host'): problem = adc2019system.role.get_problem(name) workers = adc2019system.role.get_workers() - # solutions = reversed(sorted(problem.get_solutions().items(), key=lambda x:x[1].timestamp)) if problem is None: return abort(404) else: - # return render_template('part_problem_status.html', problem=problem, workers=workers, solutions=solutions) return render_template('part_problem_status.html', problem=problem, workers=workers) else: return abort(404) -@webui.route('/part/problem_solution/') -def webui_part_solution_status(name=None): - - if name is None: - return abort(404) - - if (adc2019system.role is not None) and (adc2019system.role.type == 'host'): - problem = adc2019system.role.get_problem(name) - solutions = reversed(sorted(problem.get_solutions().items(), key=lambda x:x[1].timestamp)) - if problem is None: - return abort(404) - else: - return render_template('part_solution_status.html', problem=problem, solutions=solutions) - else: - return abort(404) - @webui.route('/api/', methods=['GET', 'POST']) def webui_api(cmd=None): diff --git a/roles/host.py b/roles/host.py index cb5eade..7289673 100644 --- a/roles/host.py +++ b/roles/host.py @@ -404,7 +404,8 @@ class Request(object): def set_running(self): self.is_processed = True - self.start_time = time.time() + if self.start_time is None: + self.start_time = time.time() def store_response(self, data): # worker = data['worker'] diff --git a/static/js/adc2019.js b/static/js/adc2019.js index 336bfe2..b3d4719 100644 --- a/static/js/adc2019.js +++ b/static/js/adc2019.js @@ -168,22 +168,23 @@ class StatusView { update_status_view(){ var _this = this; - $.ajax({ - type: 'GET', - dataType: 'html', - url: '/part/request/' + _this.problem_key - }).done((d) => { - _this.container.find('#request-table-container').empty(); - _this.container.find('#request-table-container').html(d); + + var solvers = new Array(); + + _this.container.find('#solver-list-table-wrapper .chk-solver:checked').each((i, el) => { + var _val = $(el).val(); + solvers.push(_val); }); + console.log(solvers); $.ajax({ type: 'GET', dataType: 'html', - url: '/part/problem_solution/' + _this.problem_key + url: '/part/problem_status/' + _this.problem_key }).done((d) => { - _this.container.find('#solution-table-container').empty(); - _this.container.find('#solution-table-container').html(d); + + _this.container.find('#problem-status-list-container').empty(); + _this.container.find('#problem-status-list-container').html(d); _this.container.find('.solution-detail-row.valid-solution td').click((e) => { var solution_id = $(e.target).parent("tr").data("solution-id"); diff --git a/templates/part_problem_status.html b/templates/part_problem_status.html index 74fde3f..2c91e9d 100644 --- a/templates/part_problem_status.html +++ b/templates/part_problem_status.html @@ -47,18 +47,7 @@ -
-

リクエスト一覧

-
- -
-
- -
-

処理結果一覧

-
- -
+
diff --git a/templates/part_problem_status_list.html b/templates/part_problem_status_list.html new file mode 100644 index 0000000..dbaaeb6 --- /dev/null +++ b/templates/part_problem_status_list.html @@ -0,0 +1,49 @@ +
+

リクエスト一覧

+
+ + + {% for r in status %} + + + + + {% endfor %} + +
{{r['worker']}}{{r['status']}}
+
+
+ +
+

処理結果一覧

+
+ + + + + + + + + + {% for k, v in solutions %} + {% set tr_class = '' %} + {% set tr_class = tr_class + ' submit-solution' if k == problem.best_solution else '' %} + {% set tr_class = tr_class + ' valid-solution' if v.is_valid_solution() else '' %} + + + + + + {% endfor %} + +
TimestampClientScore
{{v.timestamp_str}}{{v.worker}} + {% if v.is_valid_solution() %} + {{v.score}} ({{v.size_str}}) + {% else %} + {{v.status}} + {% endif %} + {{v.nlcheck}} +
+
+
diff --git a/templates/part_request_status.html b/templates/part_request_status.html deleted file mode 100644 index 9b7c880..0000000 --- a/templates/part_request_status.html +++ /dev/null @@ -1,12 +0,0 @@ -
- - - {% for r in status %} - - - - - {% endfor %} - -
{{r['worker']}}{{r['status']}}
-
-- 2.22.0