Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6164] allow monthly metrics reports on multiple subjects #10718

Conversation

aaxelb
Copy link
Contributor

@aaxelb aaxelb commented Aug 23, 2024

Purpose

allow monthly reports for each institution or each institutional user account

Changes

replace DailyReport.DAILY_UNIQUE_FIELDS with UNIQUE_TOGETHER_FIELDS on both DailyReport and MonthlyReport

QA Notes

Please make verification statements inspired by your code and what your code touches.

  • Verify
  • Verify

What are the areas of risk?

Any concerns/considerations/questions that development raised?

Documentation

Side Effects

Ticket

@aaxelb aaxelb force-pushed the feature/unique-together-monthly-reports branch 2 times, most recently from 45854c5 to c1745fe Compare August 23, 2024 20:30
replace `DailyReport.DAILY_UNIQUE_FIELDS` with `UNIQUE_TOGETHER_FIELDS`
on both `DailyReport` and `MonthlyReport`, so we can have (for example)
monthly reports for each institution or each institutional user account
@aaxelb aaxelb force-pushed the feature/unique-together-monthly-reports branch from c1745fe to 9923f46 Compare August 23, 2024 20:55
Copy link
Contributor

@Johnetordoff Johnetordoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some problems with the code here, but it's acceptable.

except AttributeError:
pass
else:
# Set the document id to a hash of "unique together" fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a lot of comments for a simple set_id function, there's a code smell here that this is over engineered.

@@ -46,9 +46,9 @@ def __str__(self):
return f'{self.year}-{self.month:0>2}'

def target_month(self):
return datetime.datetime(self.year, self.month, 1, tzinfo=pytz.utc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changing?

assert blah_report.meta.id == expected_blah
mock_save.reset_mock()

expected_fleh = '385700db282f6d6089a0d21836db5ee8423f548615e515b6e034bcc90a14500f'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes this different, break these up by case.

@@ -66,26 +72,31 @@ class Meta:
dynamic = metrics.MetaField('strict')
source = metrics.MetaField(enabled=True)

def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)
assert 'report_yearmonth' in cls.UNIQUE_TOGETHER_FIELDS, f'MonthlyReport subclasses must have "report_yearmonth" in UNIQUE_TOGETHER_FIELDS (on {cls.__qualname__}, got {cls.UNIQUE_TOGETHER_FIELDS})'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unnecessary KISS.

@Johnetordoff Johnetordoff merged commit a29eb75 into CenterForOpenScience:feature/insti-dash-improv Aug 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants