Skip to content

Commit 3d88f7d

Browse files
authored
Use started/finished instead of job_start/end_datetime (#1906)
1 parent fb642dd commit 3d88f7d

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
lines changed

pygeoapi/api/processes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def get_jobs(api: API, request: APIRequest,
283283
# Here we do sort again in case the provider doesn't support
284284
# pagination yet and always returns all jobs.
285285
jobs = sorted(jobs_data['jobs'],
286-
key=lambda k: k['job_start_datetime'],
286+
key=lambda k: k['started'],
287287
reverse=True)
288288
numberMatched = jobs_data['numberMatched']
289289

@@ -319,8 +319,8 @@ def get_jobs(api: API, request: APIRequest,
319319
'message': job_['message'],
320320
'progress': job_['progress'],
321321
'parameters': job_.get('parameters'),
322-
'job_start_datetime': job_['job_start_datetime'],
323-
'job_end_datetime': job_['job_end_datetime']
322+
'started': job_['started'],
323+
'finished': job_['finished']
324324
}
325325

326326
# TODO: translate

pygeoapi/process/manager/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def _execute_handler_sync(self, p: BaseProcessor, job_id: str,
305305
current_status = JobStatus.successful
306306

307307
job_update_metadata = {
308-
'job_end_datetime': datetime.utcnow().strftime(
308+
'finished': datetime.utcnow().strftime(
309309
DATETIME_FORMAT),
310310
'status': current_status.value,
311311
'location': str(job_filename),
@@ -336,7 +336,7 @@ def _execute_handler_sync(self, p: BaseProcessor, job_id: str,
336336
}
337337
LOGGER.exception(err)
338338
job_metadata = {
339-
'job_end_datetime': datetime.utcnow().strftime(
339+
'finished': datetime.utcnow().strftime(
340340
DATETIME_FORMAT),
341341
'status': current_status.value,
342342
'location': None,
@@ -432,8 +432,8 @@ def execute_process(
432432
'type': 'process',
433433
'identifier': job_id,
434434
'process_id': process_id,
435-
'job_start_datetime': datetime.utcnow().strftime(DATETIME_FORMAT),
436-
'job_end_datetime': None,
435+
'started': datetime.utcnow().strftime(DATETIME_FORMAT),
436+
'finished': None,
437437
'status': current_status.value,
438438
'location': None,
439439
'mimetype': 'application/octet-stream',

pygeoapi/templates/jobs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
<tr>
2626
<td class="small"><a href="{{ config['server']['url'] }}/jobs/{{ job.jobID}}">{{ job.jobID }}</a></td>
2727
<td class="small"><a href="{{ config['server']['url'] }}/processes/{{ job.processID}}">{{ job.processID }}</a></td>
28-
<td><abbr title="{{ job.job_start_datetime|format_datetime }}">{{ job.job_start_datetime|format_datetime }}</abbr></td>
28+
<td><abbr title="{{ job.started|format_datetime }}">{{ job.started|format_datetime }}</abbr></td>
2929
<td>
3030
{% if job.status == 'running' %}
31-
{{ job.job_start_datetime|format_duration(data.now) }}
31+
{{ job.started|format_duration(data.now) }}
3232
{% else %}
33-
{{ job.job_start_datetime|format_duration(job.job_end_datetime) }}
33+
{{ job.started|format_duration(job.finished) }}
3434
{% endif %}
3535
</td>
3636
<td>

pygeoapi/templates/jobs/job.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ <h4><label for="progress">{% trans %}Progress{% endtrans %}</label></h4>
3737
<h4><label for="runtime">{% trans %}Duration{% endtrans %}</label></h4>
3838
<p><span id="runtime">
3939
{% if data['jobs']['status'] == 'running' %}
40-
{{ data['jobs']['job_start_datetime']|format_duration(data.now) }}
40+
{{ data['jobs']['started']|format_duration(data.now) }}
4141
{% else %}
42-
{{ data['jobs']['job_start_datetime']|format_duration(data['jobs']['job_end_datetime']) }}
42+
{{ data['jobs']['started']|format_duration(data['jobs']['finished']) }}
4343
{% endif %}
4444
</span></p>
4545
<h4><label for="starttime">{% trans %}Started processing{% endtrans %}</label></h4>
46-
<p><span id="starttime">{{ data['jobs']['job_start_datetime']|format_datetime }}</span></p>
46+
<p><span id="starttime">{{ data['jobs']['started']|format_datetime }}</span></p>
4747
<h4><label for="endtime">{% trans %}Finished processing{% endtrans %}</label></h4>
48-
<p><span id="endtime">{{ data['jobs']['job_end_datetime']|format_datetime }}</span></p>
48+
<p><span id="endtime">{{ data['jobs']['finished']|format_datetime }}</span></p>
4949

5050
<h3>{% trans %}Links{% endtrans %}</h3>
5151
<ul>

tests/data/postgres_manager_full_structure.backup.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ CREATE TABLE public.jobs (
3434
type character varying DEFAULT 'process'::character varying NOT NULL,
3535
identifier character varying NOT NULL,
3636
process_id character varying NOT NULL,
37-
job_start_datetime timestamp without time zone,
38-
job_end_datetime timestamp without time zone,
37+
started timestamp without time zone,
38+
finished timestamp without time zone,
3939
status character varying NOT NULL,
4040
location character varying,
4141
mimetype character varying,
@@ -65,4 +65,3 @@ GRANT ALL ON SCHEMA public TO PUBLIC;
6565
--
6666
-- PostgreSQL database dump complete
6767
--
68-

tests/test_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def test_get_job_result_binary(config):
8484
"type": "process",
8585
"identifier": job_id,
8686
"process_id": "dummy",
87-
"job_start_datetime": "2024-08-22T12:00:00.000000Z",
88-
"job_end_datetime": "2024-08-22T12:00:01.000000Z",
87+
"started": "2024-08-22T12:00:00.000000Z",
88+
"finished": "2024-08-22T12:00:01.000000Z",
8989
"status": "successful",
9090
"location": nc_file,
9191
"mimetype": "application/x-netcdf",

0 commit comments

Comments
 (0)