Skip to content

Commit

Permalink
Merge pull request #608 from oda-hub/job_id-inside-matrix-message
Browse files Browse the repository at this point in the history
Job id inside matrix message
  • Loading branch information
burnout87 authored Oct 20, 2023
2 parents a3a1e09 + 03a8e6e commit f5703b5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cdci_data_analysis/flask_app/templates/matrix_message.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Dear User,<br>
<br>
you receive this message because at {{ request.time_request | timestamp2isot }} ( {{ request.time_request | humanize_age }} ago ) you submitted a request
for a {{ request.product_type }} from the service provided by {{ oda_site.site_name }} available at the URL {{ oda_site.frontend_url }}.<br>
for a {{ request.product_type }} (job_id: {{ request.job_id[:8] }}) from the service provided by {{ oda_site.site_name }} available at the URL {{ oda_site.frontend_url }}.<br>
<br>
{% if request.status == "submitted" %}
The request has been submitted, and once products will be ready, you will receive a new message.<br>
Expand Down
16 changes: 16 additions & 0 deletions cdci_data_analysis/pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,22 @@ class DispatcherJobState:
],
}

generalized_matrix_patterns = {
'time_request_str': [
r'(because at )([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.*?)( \()',
'(requested at )(.*? .*?)( job_id:)'
],
'token_exp_time_str': [
'(and will be valid until )(.*? .*?)(.<br>)'
],
'products_url': [
'(href=")(.*?)(">url)',
],
'job_id': [
'(job_id: )(.*?)(\) from)'
],
}

ignore_patterns = [
r'\( .*?ago \)',
r'&#34;token&#34;:.*?,',
Expand Down
2 changes: 1 addition & 1 deletion tests/reference_matrix_messages/done.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Dear User,<br>
<br>
you receive this message because at 2021-08-19 17:24:51 ( 0.0 seconds ago ) you submitted a request
for a dummy from the service provided by University of Geneva available at the URL PRODUCTS_URL.<br>
for a dummy (job_id: ac3f746e) from the service provided by University of Geneva available at the URL PRODUCTS_URL.<br>
<br>

The platform have <b>finished</b> processing your request.<br>
Expand Down
2 changes: 1 addition & 1 deletion tests/reference_matrix_messages/failed.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Dear User,<br>
<br>
you receive this message because at 2021-08-19 17:24:51 ( 0.0 seconds ago ) you submitted a request
for a dummy from the service provided by University of Geneva available at the URL PRODUCTS_URL.<br>
for a dummy (job_id: ac3f746e) from the service provided by University of Geneva available at the URL PRODUCTS_URL.<br>
<br>

Your request has <b>failed</b>. Sorry for that! You will be further contacted by our team.<br>
Expand Down
2 changes: 1 addition & 1 deletion tests/reference_matrix_messages/submitted-dummy.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Dear User,<br>
<br>
you receive this message because at 2021-08-19 17:24:51 ( 0.0 seconds ago ) you submitted a request
for a dummy from the service provided by University of Geneva available at the URL PRODUCTS_URL.<br>
for a dummy (job_id: ac3f746e) from the service provided by University of Geneva available at the URL PRODUCTS_URL.<br>
<br>

The request has been submitted, and once products will be ready, you will receive a new message.<br>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_matrix_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def get_incident_report_matrix_message(**matrix_message_args):

def adapt_html(html_content, patterns=None, **matrix_message_args,):
if patterns is None:
patterns = DispatcherJobState.generalized_patterns
patterns = DispatcherJobState.generalized_matrix_patterns
for arg, patterns in patterns.items():
if arg in matrix_message_args and matrix_message_args[arg] is not None:
for pattern in patterns:
Expand Down

0 comments on commit f5703b5

Please sign in to comment.