Navigation Menu

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

Update references in file-input SchemaResponseBlocks to match registration_responses post-archival #9804

Conversation

jwalz
Copy link
Collaborator

@jwalz jwalz commented Oct 15, 2021

Purpose

The last thing archiver does is update file references in registration_responses, these changes were not being carried over to the initial SchemaResponse. Whoops.

Changes

  • Add an _update_file_references function to SchemaResponse that specifically identifies SchemaResponseBlocks for file-input-blocks and updates them without worrying about state
  • Call this function after archiver fixes the registration_response references

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

Copy link
Member

@mfraezz mfraezz left a comment

Choose a reason for hiding this comment

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

LGTM 🌟

file_block_ids = self.schema.schema_blocks.filter(
block_type='file-input'
).values_list('id', flat=True)
if not file_block_ids:
Copy link
Member

Choose a reason for hiding this comment

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

Huh. I thought that bool(<empty QuerySet>) used to evaluate to True, which caused some API bugs in the past, but looks like that's not the case anymore.

In [1]: pppids = PreprintProvider.objects.filter(name=None).values_list('name', flat=True)

In [2]: pppids
Out[2]: <QuerySet []>

In [3]: bool(pppids)
Out[3]: False

Was going to suggest .exists(), but that's unnecessary; it would be slightly more efficient than evaluating the whole query here, but the result should be cached when it's used below, leading to no net improvement.

@jwalz jwalz merged commit 4823da7 into CenterForOpenScience:develop Oct 15, 2021
mfraezz pushed a commit that referenced this pull request Oct 18, 2021
…ation_responses post-archival (#9804)

* Update references in file-input blocks to match registration_responses post-archival


Co-authored-by: Jon Walz <jonwalz@Admins-MBP.lan>
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.

None yet

2 participants