diff --git a/main.py b/main.py index 8744b06c61c2349151b1d12e6c44150d9aaecf27..8d0c4ae48a4e062e4bf0b4ee9433a04da3c0e22d 100644 --- a/main.py +++ b/main.py @@ -61,11 +61,28 @@ 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_problem_status.html', problem=problem, workers=workers, solutions=solutions) + return render_template('part_solution_status.html', problem=problem, solutions=solutions) else: return abort(404) diff --git a/static/js/adc2019.js b/static/js/adc2019.js index 02082ed1634f2f622684873d858a38ed962dd98a..bdd1a45194ab4c88e4f040a02a4941da66350581 100644 --- a/static/js/adc2019.js +++ b/static/js/adc2019.js @@ -41,13 +41,6 @@ class StatusView { _this.fire('refresh'); }); - _this.container.find('.solution-detail-row.valid-solution td').click((e) => { - var solution_id = $(e.target).parent("tr").data("solution-id"); - var problem_name = $(e.target).parent("tr").data("problem"); - var viewer_url = "/viewer#" + problem_name + "/" + solution_id; - window.open(viewer_url, "_blank"); - }); - _this.container.find('#chk-solver-all').prop('checked', false); _this.container.find('#chk-solver-all').on('change', (e) => { @@ -64,7 +57,7 @@ class StatusView { }).trigger('change'); _this.request_refresh_timer = setInterval((function _t(){ - _this.get_request_status(); + _this.update_status_view(); return _t; }()), 1000); }); @@ -97,24 +90,6 @@ class StatusView { contentType: 'application/json' }).done((d) => { console.log(d); - // var request_id = d['request_id']; - // var timeout = d['timeout']; - - // _this.container.find('#solver-processing-modal').modal({ - // backdrop: 'static', - // keyboard: false, - // show: true - // }); - // _this.container.find('#solver-processing-modal').on('hidden.bs.modal', function(e){ - // clearInterval(_this.request_refresh_timer); - // _this.show_problem(); - // _this.fire('refresh'); - // }) - - // _this.container.find('.stop-button').click(()=>{ - // _this.stop_solver(); - // }); - }); } @@ -170,7 +145,7 @@ class StatusView { }); } - get_request_status(){ + update_status_view(){ var _this = this; $.ajax({ type: 'GET', @@ -180,6 +155,24 @@ class StatusView { _this.container.find('#request-table-container').empty(); _this.container.find('#request-table-container').html(d); }); + + $.ajax({ + type: 'GET', + dataType: 'html', + url: '/part/problem_solution/' + _this.problem_key + }).done((d) => { + _this.container.find('#solution-table-container').empty(); + _this.container.find('#solution-table-container').html(d); + + _this.container.find('.solution-detail-row.valid-solution td').click((e) => { + var solution_id = $(e.target).parent("tr").data("solution-id"); + var problem_name = $(e.target).parent("tr").data("problem"); + var viewer_url = "/viewer#" + problem_name + "/" + solution_id; + window.open(viewer_url, "_blank"); + }); + + _this.fire('refresh'); + }); } // システム詳細画面を表示 diff --git a/templates/part_problem_status.html b/templates/part_problem_status.html index 176f662a27aa2e31c49ed2c17d15bdcfa7ce536a..74fde3f477bf5e68e941a79b1b5b1555166695a1 100644 --- a/templates/part_problem_status.html +++ b/templates/part_problem_status.html @@ -56,33 +56,9 @@

処理結果一覧

- - - - - - - - - - {% 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 %} -
+
+ +
diff --git a/templates/part_solution_status.html b/templates/part_solution_status.html new file mode 100644 index 0000000000000000000000000000000000000000..517c6c488ebaf446be757a9e67dc2383365624a4 --- /dev/null +++ b/templates/part_solution_status.html @@ -0,0 +1,27 @@ + + + + + + + + + + {% 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 %} +
diff --git a/utils/data.py b/utils/data.py index 1049a1f3240ce26f05ccdaf2135aade2b7bb9b60..c6a606f2b30182d31022009738d8b6aba1cb8520 100644 --- a/utils/data.py +++ b/utils/data.py @@ -31,7 +31,7 @@ class Problem(object): self._load_problem(problem_path) if not self.solution_path is None: - solution_files = glob.glob(f'{self.solution_path}/{self.name}/*.json') + solution_files = glob.glob(f'{self.solution_path}/{self.name}/tmp-*.json') for v in solution_files: solution = Solution(solution_file=v) solution_id = solution.get_id() @@ -364,7 +364,7 @@ class Problem(object): outdir = f"{self.solution_path}/{self.name}" if not os.path.exists(outdir): os.mkdir(outdir) - outpath = f"{outdir}/{data['request_id']}-{data['worker']}-p{data['part_id']}.json".replace(":", ".") + outpath = f"{outdir}/part-{data['request_id']}-{data['worker']}-p{data['part_id']}.json".replace(":", ".") with open(outpath, 'w') as fp: json.dump(self.get_dict(), fp, indent=4) @@ -540,7 +540,7 @@ class Solution(object): outdir = f"{basedir}/{self.problem}" if not os.path.exists(outdir): os.mkdir(outdir) - outpath = f"{outdir}/{self.request_id}-{self.worker}.json".replace(":", ".") + outpath = f"{outdir}/tmp-{self.request_id}-{self.worker}.json".replace(":", ".") with open(outpath, 'w') as fp: json.dump(self.get_dict(), fp, indent=4)