Skip to content

Commit

Permalink
Add reports to scheduled table (#3787)
Browse files Browse the repository at this point in the history
Co-authored-by: ammar92 <[email protected]>
Co-authored-by: stephanie0x00 <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent e482bbc commit d5b3dfa
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 25 deletions.
5 changes: 4 additions & 1 deletion rocky/reports/runner/report_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def run(self, report_task: ReportTask) -> None:
connector = OctopoesAPIConnector(
settings.OCTOPOES_API, report_task.organisation_id, timeout=settings.ROCKY_OUTGOING_REQUEST_TIMEOUT
)
recipe = connector.get(Reference.from_str(f"ReportRecipe|{report_task.report_recipe_id}"), valid_time)
recipe_ref = Reference.from_str(f"ReportRecipe|{report_task.report_recipe_id}")
recipe = connector.get(recipe_ref, valid_time)

report_types = [get_report_by_id(report_type_id) for report_type_id in recipe.report_types]
oois = []
Expand Down Expand Up @@ -88,6 +89,7 @@ def run(self, report_task: ReportTask) -> None:
report_data,
post_processed_data,
aggregate_report,
recipe_ref,
)
else:
subreport_names = []
Expand Down Expand Up @@ -127,6 +129,7 @@ def run(self, report_task: ReportTask) -> None:
report_data,
subreport_names,
parent_report_name,
recipe_ref,
)

self.bytes_client.organization = None
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<tr>
<th scope="col">{% translate "Name" %}</th>
<th scope="col">{% translate "Report type" %}</th>
<th scope="col">{% translate "Input Objects" %}</th>
<th scope="col">{% translate "Reference date" %}</th>
<th scope="col">{% translate "Creation date" %}</th>
<th scope="col" class="nowrap">{% translate "Input objects" %}</th>
<th scope="col" class="nowrap">{% translate "Reference date" %}</th>
<th scope="col" class="nowrap">{% translate "Creation date" %}</th>
{% if report.children_reports %}<th scope="col"></th>{% endif %}
</tr>
</thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
<caption class="visually-hidden">{% translate "Scheduled Reports:" %}</caption>
<thead>
<tr>
<th scope="col">{% translate "Name" %}</th>
<th scope="col" class="nowrap">{% translate "Name" %}</th>
<th scope="col">{% translate "Report type" %}</th>
<th scope="col">{% translate "Input Object" %}</th>
<th scope="col">{% translate "Reference date" %}</th>
<th scope="col">{% translate "Creation date" %}</th>
<th scope="col">{% translate "Input object" %}</th>
<th scope="col" class="nowrap">{% translate "Reference date" %}</th>
<th scope="col" class="nowrap">{% translate "Creation date" %}</th>
</tr>
</thead>
<tbody>
Expand All @@ -77,7 +77,13 @@
<span class="label tags-color-{{ report.report_type|get_report_type_label_style }}">{{ report.report_type|get_report_type_name }}</span>
</td>
<td>
{% for ooi in report.input_oois %}<span>{{ ooi|human_readable }}</span>{% endfor %}
{% if report.input_oois|length == 1 %}
{% with ooi=report.input_oois.0 %}
<a href="{% ooi_url 'ooi_detail' ooi organization.code query=ooi.mandatory_fields %}">{{ ooi|human_readable }}</a>
{% endwith %}
{% else %}
{{ report.input_oois|length }}
{% endif %}
</td>
<td class="nowrap">{{ report.observed_at|date }}</td>
<td class="nowrap">{{ report.date_generated }}</td>
Expand Down
6 changes: 0 additions & 6 deletions rocky/reports/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,6 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
"asc_desc": self.sorting_order,
}

parent_report_type = None
if self.report_type == AggregateOrganisationReport:
parent_report_type = AggregateOrganisationReport.id
elif not self.report_type and subreport_name_format:
parent_report_type = ConcatenatedReport.id

parent_report_type = None
if self.report_type is not None:
parent_report_type = self.report_type.id
Expand Down
5 changes: 5 additions & 0 deletions rocky/reports/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def save_report_data(
report_data,
report_names,
parent_report_name,
report_recipe: Reference | None = None,
) -> Report | None:
if len(report_data) == 0:
return None
Expand Down Expand Up @@ -97,6 +98,7 @@ def save_report_data(
observed_at=observed_at,
parent_report=None,
has_parent=False,
report_recipe=report_recipe,
)

create_ooi(octopoes_api_connector, bytes_client, parent_report_ooi, observed_at)
Expand Down Expand Up @@ -185,6 +187,7 @@ def save_report_data(
observed_at=observed_at,
parent_report=None,
has_parent=False,
report_recipe=report_recipe,
)

create_ooi(octopoes_api_connector, bytes_client, parent_report_ooi, observed_at)
Expand All @@ -202,6 +205,7 @@ def save_aggregate_report_data(
report_data,
post_processed_data,
aggregate_report,
report_recipe: Reference | None = None,
) -> Report:
observed_at = get_observed_at

Expand Down Expand Up @@ -231,6 +235,7 @@ def save_aggregate_report_data(
observed_at=observed_at,
parent_report=None,
has_parent=False,
report_recipe=report_recipe,
)
create_ooi(octopoes_api_connector, bytes_client, report_ooi, observed_at)

Expand Down
20 changes: 10 additions & 10 deletions rocky/rocky/locale/django.pot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-07 10:53+0000\n"
"POT-Creation-Date: 2024-11-07 11:24+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -4122,7 +4122,7 @@ msgid "Reports:"
msgstr ""

#: reports/templates/report_overview/report_history_table.html
msgid "Input Objects"
msgid "Input objects"
msgstr ""

#: reports/templates/report_overview/report_history_table.html
Expand Down Expand Up @@ -4220,10 +4220,8 @@ msgid "Scheduled Reports:"
msgstr ""

#: reports/templates/report_overview/scheduled_reports_table.html
#: reports/templates/report_overview/subreports_table.html
#: rocky/templates/tasks/boefjes.html
#: rocky/templates/tasks/plugin_detail_task_list.html
msgid "Input Object"
#: rocky/templates/tasks/boefje_task_detail.html
msgid "Input object"
msgstr ""

#: reports/templates/report_overview/scheduled_reports_table.html
Expand Down Expand Up @@ -4260,6 +4258,12 @@ msgstr ""
msgid "Subreports:"
msgstr ""

#: reports/templates/report_overview/subreports_table.html
#: rocky/templates/tasks/boefjes.html
#: rocky/templates/tasks/plugin_detail_task_list.html
msgid "Input Object"
msgstr ""

#: reports/templates/summary/report_asset_overview.html
msgid ""
"The objects listed in the table below were used to generate this report. For "
Expand Down Expand Up @@ -6538,10 +6542,6 @@ msgstr ""
msgid "Download meta data"
msgstr ""

#: rocky/templates/tasks/boefje_task_detail.html
msgid "Input object"
msgstr ""

#: rocky/templates/tasks/boefjes.html
#, python-format
msgid ""
Expand Down

0 comments on commit d5b3dfa

Please sign in to comment.