Skip to content

Commit

Permalink
add report_yearmonth to insti-metrics serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Dec 5, 2024
1 parent 9dad00c commit 28c5587
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/institutions/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ class Meta:
})

id = IDField(source='meta.id', read_only=True)
report_yearmonth = YearmonthField(read_only=True)
user_name = ser.CharField(read_only=True)
department = ser.CharField(read_only=True, source='department_name')
orcid_id = ser.CharField(read_only=True)
Expand Down Expand Up @@ -372,6 +373,7 @@ class Meta:

id = IDField(read_only=True)

report_yearmonth = YearmonthField(read_only=True)
user_count = ser.IntegerField(read_only=True)
public_project_count = ser.IntegerField(read_only=True)
private_project_count = ser.IntegerField(read_only=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def test_get_report(self, app, url, institutional_admin, institution, reports, u
assert data['type'] == 'institution-summary-metrics'

attributes = data['attributes']
assert attributes['report_yearmonth'] == '2024-08'
assert attributes['user_count'] == 200
assert attributes['public_project_count'] == 150
assert attributes['private_project_count'] == 125
Expand Down Expand Up @@ -254,6 +255,7 @@ def test_get_report_with_multiple_months_and_institutions(

attributes = data['attributes']

assert attributes['report_yearmonth'] == '2024-09'
assert attributes['user_count'] == 250
assert attributes['public_project_count'] == 200
assert attributes['private_project_count'] == 150
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ def test_get_report_formats_csv_tsv(self, app, url, institutional_admin, institu
response_body = resp.text
expected_response = [
[
'report_yearmonth',
'account_creation_date',
'department',
'embargoed_registration_count',
Expand All @@ -460,6 +461,7 @@ def test_get_report_formats_csv_tsv(self, app, url, institutional_admin, institu
'user_name'
],
[
'2024-08',
'2018-02',
'Center, \t Greatest Ever',
'1',
Expand Down Expand Up @@ -512,6 +514,7 @@ def test_csv_tsv_ignores_pagination(self, app, url, institutional_admin, institu
month_last_login='2018-02',
)
expected_data.append([
'2024-08',
'2018-02',
'QBatman',
'1',
Expand Down Expand Up @@ -552,6 +555,7 @@ def test_csv_tsv_ignores_pagination(self, app, url, institutional_admin, institu
response_rows = list(reader)
# Validate header row
expected_header = [
'report_yearmonth',
'account_creation_date',
'department',
'embargoed_registration_count',
Expand Down Expand Up @@ -606,6 +610,7 @@ def test_get_report_format_table_json(self, app, url, institutional_admin, insti
response_data = json.loads(resp.body)
expected_data = [
{
'report_yearmonth': '2024-08',
'account_creation_date': '2018-02',
'department': 'Safety "The Wolverine" Weapon X',
'embargoed_registration_count': 1,
Expand Down

0 comments on commit 28c5587

Please sign in to comment.