Skip to content

[ ENG-9762] Improve moderator and user files tests to properly reflect digest code#254

Open
Johnetordoff wants to merge 8 commits into
feature/notification-refactor-p2-sfrom
fix/batch-sending-digest
Open

[ ENG-9762] Improve moderator and user files tests to properly reflect digest code#254
Johnetordoff wants to merge 8 commits into
feature/notification-refactor-p2-sfrom
fix/batch-sending-digest

Conversation

@Johnetordoff

@Johnetordoff Johnetordoff commented Nov 13, 2025

Copy link
Copy Markdown
Owner

Make changes to help working of digest logic and tests.

Purpose

Changes

  • Changes beat schedule to test digests better
  • improves digest code to no longer use subscribers
  • improves tests to capture real digest behavior.

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

https://openscience.atlassian.net/browse/ENG-9762

@Johnetordoff Johnetordoff changed the title improve moderator and user files tests to properly reflect digest cod… [ ENG-9762] Improve moderator and user files tests to properly reflect digest code Nov 13, 2025
@Johnetordoff
Johnetordoff marked this pull request as ready for review November 13, 2025 20:15
Comment thread notifications/tasks.py Outdated
if provider is None:
log_message(f"subscribed_object fpr {subscribed_object} does not exist")
log_message(f"provider for subscribed_object {subscribed_object} does not exist")
email_task.status = 'PROVIDER NOT FOUND'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The email_task.status is invalid in lines 122, 129, 136

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I fixed it.

Comment thread notifications/tasks.py
log_message(f"subscribed_object fpr {subscribed_object} does not exist")
log_message(f"provider for subscribed_object {subscribed_object} does not exist")
email_task.status = 'PROVIDER NOT FOUND'
email_task.save()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It looks like this is the place for the email_task.error_message

NotificationType.Type.PROVIDER_NEW_PENDING_WITHDRAW_REQUESTS.instance.emit(
user=recipient,
subscribed_object=provider,
subscribed_object=resource,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I have some concerns about changing "subscribed_object" to "resource" instead of "provider."
Currently, with "subscribed_object" set to "provider," there is one subscription for each user-provider pair. However, using "resource" for "subscribed_object" would result in a subscription for each user-resource pair. This would create a large number of records in the database that would be difficult to work with.

Here's an example:
One provider
10 moderators
100 resources.
Using the user-provider pair would result in 10 records.
However, if we use the user-resource pair, we will have 1,000 records. If a user updates the frequency, 100 records must be updated.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree and I don't see any benefits for the change. Let's keep using user-provider pair.

NotificationType.Type.PROVIDER_NEW_PENDING_WITHDRAW_REQUESTS.instance.emit(
user=recipient,
subscribed_object=provider,
subscribed_object=resource,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree and I don't see any benefits for the change. Let's keep using user-provider pair.

Comment on lines +636 to +641
'schedule': crontab(minute='*/10'), # Daily 12 a.m (ten minutes for testing purposes)
'kwargs': {'dry_run': False},
},
'send_users_digest_email': {
'task': 'notifications.tasks.send_users_digest_email',
'schedule': crontab(minute=0, hour=5), # Daily 12 a.m
'schedule': crontab(minute='*/10'), # Daily 12 a.m (ten minutes for testing purposes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Don't change defaults, these needs to be changed in each server's local.py

'task': 'scripts.triggered_mails',
'schedule': crontab(minute=0, hour=5), # Daily 12 a.m
'kwargs': {'dry_run': False},
'kwargs': {'dry_run': True}, # For no_login messages

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is good. We should have True for defaults and set it accordingly in each server's local.py.

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.

3 participants