Skip to content

Commit

Permalink
Use started/finished instead of job_start/end_datetime (#1906)
Browse files Browse the repository at this point in the history
  • Loading branch information
vprivat-ads authored Jan 21, 2025
1 parent fb642dd commit 3d88f7d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions pygeoapi/api/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def get_jobs(api: API, request: APIRequest,
# Here we do sort again in case the provider doesn't support
# pagination yet and always returns all jobs.
jobs = sorted(jobs_data['jobs'],
key=lambda k: k['job_start_datetime'],
key=lambda k: k['started'],
reverse=True)
numberMatched = jobs_data['numberMatched']

Expand Down Expand Up @@ -319,8 +319,8 @@ def get_jobs(api: API, request: APIRequest,
'message': job_['message'],
'progress': job_['progress'],
'parameters': job_.get('parameters'),
'job_start_datetime': job_['job_start_datetime'],
'job_end_datetime': job_['job_end_datetime']
'started': job_['started'],
'finished': job_['finished']
}

# TODO: translate
Expand Down
8 changes: 4 additions & 4 deletions pygeoapi/process/manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def _execute_handler_sync(self, p: BaseProcessor, job_id: str,
current_status = JobStatus.successful

job_update_metadata = {
'job_end_datetime': datetime.utcnow().strftime(
'finished': datetime.utcnow().strftime(
DATETIME_FORMAT),
'status': current_status.value,
'location': str(job_filename),
Expand Down Expand Up @@ -336,7 +336,7 @@ def _execute_handler_sync(self, p: BaseProcessor, job_id: str,
}
LOGGER.exception(err)
job_metadata = {
'job_end_datetime': datetime.utcnow().strftime(
'finished': datetime.utcnow().strftime(
DATETIME_FORMAT),
'status': current_status.value,
'location': None,
Expand Down Expand Up @@ -432,8 +432,8 @@ def execute_process(
'type': 'process',
'identifier': job_id,
'process_id': process_id,
'job_start_datetime': datetime.utcnow().strftime(DATETIME_FORMAT),
'job_end_datetime': None,
'started': datetime.utcnow().strftime(DATETIME_FORMAT),
'finished': None,
'status': current_status.value,
'location': None,
'mimetype': 'application/octet-stream',
Expand Down
6 changes: 3 additions & 3 deletions pygeoapi/templates/jobs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<tr>
<td class="small"><a href="{{ config['server']['url'] }}/jobs/{{ job.jobID}}">{{ job.jobID }}</a></td>
<td class="small"><a href="{{ config['server']['url'] }}/processes/{{ job.processID}}">{{ job.processID }}</a></td>
<td><abbr title="{{ job.job_start_datetime|format_datetime }}">{{ job.job_start_datetime|format_datetime }}</abbr></td>
<td><abbr title="{{ job.started|format_datetime }}">{{ job.started|format_datetime }}</abbr></td>
<td>
{% if job.status == 'running' %}
{{ job.job_start_datetime|format_duration(data.now) }}
{{ job.started|format_duration(data.now) }}
{% else %}
{{ job.job_start_datetime|format_duration(job.job_end_datetime) }}
{{ job.started|format_duration(job.finished) }}
{% endif %}
</td>
<td>
Expand Down
8 changes: 4 additions & 4 deletions pygeoapi/templates/jobs/job.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ <h4><label for="progress">{% trans %}Progress{% endtrans %}</label></h4>
<h4><label for="runtime">{% trans %}Duration{% endtrans %}</label></h4>
<p><span id="runtime">
{% if data['jobs']['status'] == 'running' %}
{{ data['jobs']['job_start_datetime']|format_duration(data.now) }}
{{ data['jobs']['started']|format_duration(data.now) }}
{% else %}
{{ data['jobs']['job_start_datetime']|format_duration(data['jobs']['job_end_datetime']) }}
{{ data['jobs']['started']|format_duration(data['jobs']['finished']) }}
{% endif %}
</span></p>
<h4><label for="starttime">{% trans %}Started processing{% endtrans %}</label></h4>
<p><span id="starttime">{{ data['jobs']['job_start_datetime']|format_datetime }}</span></p>
<p><span id="starttime">{{ data['jobs']['started']|format_datetime }}</span></p>
<h4><label for="endtime">{% trans %}Finished processing{% endtrans %}</label></h4>
<p><span id="endtime">{{ data['jobs']['job_end_datetime']|format_datetime }}</span></p>
<p><span id="endtime">{{ data['jobs']['finished']|format_datetime }}</span></p>

<h3>{% trans %}Links{% endtrans %}</h3>
<ul>
Expand Down
5 changes: 2 additions & 3 deletions tests/data/postgres_manager_full_structure.backup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ CREATE TABLE public.jobs (
type character varying DEFAULT 'process'::character varying NOT NULL,
identifier character varying NOT NULL,
process_id character varying NOT NULL,
job_start_datetime timestamp without time zone,
job_end_datetime timestamp without time zone,
started timestamp without time zone,
finished timestamp without time zone,
status character varying NOT NULL,
location character varying,
mimetype character varying,
Expand Down Expand Up @@ -65,4 +65,3 @@ GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--

4 changes: 2 additions & 2 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def test_get_job_result_binary(config):
"type": "process",
"identifier": job_id,
"process_id": "dummy",
"job_start_datetime": "2024-08-22T12:00:00.000000Z",
"job_end_datetime": "2024-08-22T12:00:01.000000Z",
"started": "2024-08-22T12:00:00.000000Z",
"finished": "2024-08-22T12:00:01.000000Z",
"status": "successful",
"location": nc_file,
"mimetype": "application/x-netcdf",
Expand Down

0 comments on commit 3d88f7d

Please sign in to comment.