Refactored reports to use pregenerated docs instead (#2831)

* Refactored reports to use pregenerated docs instead

* Fixed e2e test

* Fixed anothr bug

* Cleanup

* Fixed timezone conversion

* Updated ref files

* Updated reference files, refreshed ui/ux for report generation. Buttons toggle on and off based on if report exists

* Fixed linting errors, removed pytz

* Fixed test failure

* e2e test fix

* Speeding up unit tests

* Removed python time library that was causing performance issues with unit tests

* Updated poetry lock

* Unit test improvements

* Made change that ken reccomended
This commit is contained in:
Alex Janousek
2025-08-15 15:02:54 -04:00
committed by GitHub
parent 748c35d2df
commit 8d33f28b76
50 changed files with 632 additions and 204 deletions

View File

@@ -59,6 +59,19 @@
{% endif %}
{% endset %}
{% block maincolumn_content %}
<style>
.download-reports-container .usa-button {
padding: 0.75rem 1rem;
min-height: 48px;
justify-content: flex-start;
}
.download-reports-container .usa-icon {
width: 1.25rem;
height: 1.25rem;
flex-shrink: 0;
}
</style>
<div class="margin-bottom-8">
<h1 class="usa-sr-only">All activity</h1>
<h2 class="font-body-2xl line-height-sans-2 margin-0">All activity</h2>
@@ -164,33 +177,100 @@
</div>
{{show_pagination}}
{% if current_user.has_permissions(ServicePermission.VIEW_ACTIVITY) %}
{% if has_any_download_data %}
<h2 class="line-height-sans-2 margin-bottom-0 margin-top-4">Download recent reports</h2>
{% if has_1_day_data %}
<p class="font-body-sm">
<a href="{{ download_link_one_day }}" download="download" class="usa-link">Download all data last 24 hours (<abbr title="Comma separated values">CSV</abbr>)</a>
</p>
{% endif %}
{% if has_3_day_data %}
<p class="font-body-sm">
<a href="{{ download_link_three_day }}" download="download" class="usa-link">Download all data last 3 days (<abbr title="Comma separated values">CSV</abbr>)</a>
&emsp;
</p>
{% endif %}
{% if has_5_day_data %}
<p class="font-body-sm">
<a href="{{ download_link_five_day }}" download="download" class="usa-link">Download all data last 5 days (<abbr title="Comma separated values">CSV</abbr>)</a>
</p>
{% endif %}
{% if has_7_day_data %}
<p class="font-body-sm">
<a href="{{ download_link_seven_day }}" download="download" class="usa-link">Download all data last 7 days (<abbr title="Comma separated values">CSV</abbr>)</a>
</p>
{% endif %}
{% else %}
<h2 class="line-height-sans-2 margin-bottom-0 margin-top-4">Download recent reports</h2>
<p class="font-body-sm">No recent activity to download. Download links will appear when jobs are available.</p>
{% endif %}
<div class="usa-summary-box margin-top-4" role="region" aria-labelledby="download-reports-heading">
<div class="usa-summary-box__body">
<h2 class="usa-summary-box__heading" id="download-reports-heading">Download recent reports</h2>
<div class="usa-summary-box__text">
<p class="font-body-xs margin-bottom-3">
Reports are automatically generated daily at midnight and include data through the previous day.
Today's activity will appear in tomorrow's report.
</p>
<div class="download-reports-container maxw-tablet-lg">
<div class="margin-bottom-2">
{% if report_1_day.available %}
<a href="{{ download_link_one_day }}"
class="usa-button width-full display-flex flex-align-center"
download
aria-label="Download yesterday's report, CSV format, {{ report_1_day.size }}">
<svg class="usa-icon margin-right-2" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{{ asset_url('img/sprite.svg') }}#file_download"></use>
</svg>
<span>Yesterday&nbsp; - {{ report_1_day.size }}</span>
</a>
{% else %}
<button class="usa-button width-full"
disabled
aria-label="Yesterday's report not available - no messages were sent">
Yesterday&nbsp;&nbsp;&nbsp; - No messages sent
</button>
{% endif %}
</div>
<div class="margin-bottom-2">
{% if report_3_day.available %}
<a href="{{ download_link_three_day }}"
class="usa-button width-full display-flex flex-align-center"
download
aria-label="Download last 3 days report, CSV format, {{ report_3_day.size }}">
<svg class="usa-icon margin-right-2" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{{ asset_url('img/sprite.svg') }}#file_download"></use>
</svg>
<span>Last 3 days - {{ report_3_day.size }}</span>
</a>
{% else %}
<button class="usa-button width-full"
disabled
aria-label="Last 3 days report not available - no messages were sent">
Last 3 days - No messages sent
</button>
{% endif %}
</div>
<div class="margin-bottom-2">
{% if report_5_day.available %}
<a href="{{ download_link_five_day }}"
class="usa-button width-full display-flex flex-align-center"
download
aria-label="Download last 5 days report, CSV format, {{ report_5_day.size }}">
<svg class="usa-icon margin-right-2" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{{ asset_url('img/sprite.svg') }}#file_download"></use>
</svg>
<span>Last 5 days - {{ report_5_day.size }}</span>
</a>
{% else %}
<button class="usa-button width-full"
disabled
aria-label="Last 5 days report not available - no messages were sent">
Last 5 days - No messages sent
</button>
{% endif %}
</div>
<div class="margin-bottom-2">
{% if report_7_day.available %}
<a href="{{ download_link_seven_day }}"
class="usa-button width-full display-flex flex-align-center"
download
aria-label="Download last 7 days report, CSV format, {{ report_7_day.size }}">
<svg class="usa-icon margin-right-2" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{{ asset_url('img/sprite.svg') }}#file_download"></use>
</svg>
<span>Last 7 days - {{ report_7_day.size }}</span>
</a>
{% else %}
<button class="usa-button width-full"
disabled
aria-label="Last 7 days report not available - no messages were sent">
Last 7 days - No messages sent
</button>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
{% endblock %}