Skip to content

[ENG-10338] Registrations not becoming public when embargo ends#11748

Open
antkryt wants to merge 2 commits into
CenterForOpenScience:masterfrom
antkryt:hotfix/ENG-10338
Open

[ENG-10338] Registrations not becoming public when embargo ends#11748
antkryt wants to merge 2 commits into
CenterForOpenScience:masterfrom
antkryt:hotfix/ENG-10338

Conversation

@antkryt
Copy link
Copy Markdown
Contributor

@antkryt antkryt commented May 20, 2026

Ticket

Purpose

optimize embargo report

(Added by @cslzchen ) Here is the initial PR that implements the embargo report feature: #11637

Changes

  • optimize queries/filter logic on the db side
  • fix pagination
  • add tests

Side Effects

QE Notes

CE Notes

Documentation

Copy link
Copy Markdown
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

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

Looks good overall, there is some issue with my local admin app, so I merged into a temporary branch https://github.com/CenterForOpenScience/osf.io/tree/feature/hotfix-cr-test for me to test it.

Copy link
Copy Markdown
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

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

Left a few questions and suggestions @antkryt .

In addition, have you tested all three lists with pagination locally (not unit tests)? If not, please test it. You can tweak your pagination size to a lower value like 3 so you have less data to create.

If for some limitation, you can't test it locally or you can only test some of them, please document them.

(Note: the ticket is currently assigned to QA for creating registrations/embargoes on staging2.)

Comment thread osf/models/sanctions.py Outdated
Comment on lines +461 to +462
def non_deleted_registations(self):
return self.filter(registrations__is_deleted=False).distinct()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A good fix. It reduces the query set and removed duplicates when filter across tables. Two questions:

  • Can embargo has deleted registrations?
  • Are there any other things we can filter out further?

In addition, rename non_deleted_registations to has_non_deleted_registations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. We can delete registration via admin or it can be marked as spam, etc. after embargo is created
  2. I think there's no need to filter out further. Functions like pending_past_activation_window are implemented to match Embargo.should_be_embargoed or Embargo.should_be_completed functions which filter out only deleted registrations

Comment thread osf/models/sanctions.py Outdated
Comment on lines +482 to +484
self.pending_embargoes()
.filter(initiation_date__lte=cutoff)
.non_deleted_registations()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we filter out embargoes with deleted registrations first?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I moved this filter to the pending_embargoes()/active_embargoes() as you suggested below

Comment thread osf/models/sanctions.py Outdated
Comment on lines +482 to +484
self.pending_embargoes()
.filter(initiation_date__lte=cutoff)
.non_deleted_registations()
Copy link
Copy Markdown
Collaborator

@cslzchen cslzchen May 21, 2026

Choose a reason for hiding this comment

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

In addition, I recommend updating the pending_embargoes() directly

def pending_embargoes(exclude_deleted=false):
   ...

so that we can simply call

return (self.pending_embargoes(exclude_deleted=true).filter(initiation_date__lte=cutoff))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread osf/models/sanctions.py
Comment on lines +487 to +502
def active_past_end_date(self):
"""Active embargoes past end date (matches should_be_completed)."""
return (
self.active_embargoes()
.filter(end_date__lt=timezone.now())
.non_deleted_registations()
)

def active_upcoming(self):
"""Active embargoes with a future end date."""
return (
self.active_embargoes()
.filter(end_date__gte=timezone.now())
.non_deleted_registations()
.order_by('end_date')
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same question and suggestion for active_embargoes().

Copy link
Copy Markdown
Contributor Author

@antkryt antkryt May 22, 2026

Choose a reason for hiding this comment

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

refactored

Comment thread osf/models/sanctions.py Outdated
return (
self.pending_embargoes()
.filter(initiation_date__lte=cutoff)
.non_deleted_registations()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Finally, I see we have order_by() for active_upcoming(). So what's the consideration for no sorting for pending_past_activation_window and active_past_end_date while having sorting for active_upcoming().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In the ideal word we don't want to see any embargoes in the pending_past_activation_window/active_past_end_date (or, at least, keep their number as low as possible), so I don't see any reason to order_by. Anyway, I added ordering just in case

Comment thread admin/nodes/views.py Outdated
- active embargoes that are past their end date
- upcoming active embargoes
"""
EMBARGO_REPORT_PAGE_SIZE = 10
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not a blocker but would be great for this to be a configurable different servers. On all the non-production servers I tested, the paging functionality doesn't show up due to lack of embargoes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to website/settings.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.

2 participants