Skip to content

Commit

Permalink
add view name to file download
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Oct 25, 2024
1 parent 4472a44 commit c1dac13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/base/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@

MAX_SIZE_OF_ES_QUERY = 10000
DEFAULT_ES_NULL_VALUE = 'N/A'
REPORT_FILENAME_FORMAT = 'osf_report_{date_created}.{format_type}'
REPORT_FILENAME_FORMAT = '{view_name}_{date_created}.{format_type}'

CI_ENV = False

Expand Down
1 change: 1 addition & 0 deletions api/metrics/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def get_filename(self, renderer_context: dict, format_type: str) -> str:
if renderer_context and 'view' in renderer_context:
current_date = datetime.datetime.now().strftime('%Y-%m')
return REPORT_FILENAME_FORMAT.format(
view_name=renderer_context['view'].view_name,
date_created=current_date,
format_type=format_type,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ def test_get_report_formats_csv_tsv(self, app, url, institutional_admin, institu

current_date = datetime.datetime.now().strftime('%Y-%m')
expected_filename = REPORT_FILENAME_FORMAT.format(
view_name='institution-user-metrics',
date_created=current_date,
format_type=format_type
)
Expand Down Expand Up @@ -516,6 +517,7 @@ def test_get_report_format_json(self, app, url, institutional_admin, institution

current_date = datetime.datetime.now().strftime('%Y-%m')
expected_filename = REPORT_FILENAME_FORMAT.format(
view_name='institution-user-metrics',
date_created=current_date,
format_type='json'
)
Expand Down Expand Up @@ -601,6 +603,7 @@ def test_csv_tsv_ignores_pagination(self, app, url, institutional_admin, institu

current_date = datetime.datetime.now().strftime('%Y-%m')
expected_filename = REPORT_FILENAME_FORMAT.format(
view_name='institution-user-metrics',
date_created=current_date,
format_type=format_type
)
Expand Down

0 comments on commit c1dac13

Please sign in to comment.