Skip to content

Allow to change the privacy level of external versions #7825

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

Merged
merged 17 commits into from
Jul 1, 2021

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Jan 13, 2021

Only the field is added here,
the auth check is done in .com.

Only the field is added here,
the auth check is done in .com.
@stsewd stsewd force-pushed the privacy-level-external-versions branch from be139e2 to bef3f8b Compare January 13, 2021 15:45
@stsewd stsewd requested a review from a team January 13, 2021 16:04
@stsewd
Copy link
Member Author

stsewd commented Jan 13, 2021

Docs about privacy level would need to updated in new section added in #7823

@stsewd stsewd requested a review from ericholscher January 28, 2021 22:57
@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jun 2, 2021
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Looks like a good change with a few small nitpicks 👍

@stale stale bot removed Status: stale Issue will be considered inactive soon labels Jun 3, 2021
@stsewd
Copy link
Member Author

stsewd commented Jun 10, 2021

I have changed this PR to include the querysets from .com, now that we have moved most of them here.

(This still needs one override in .com)

@stsewd stsewd requested a review from ericholscher June 10, 2021 18:50
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Looks like a good change, but just worried about performance and if we can contain this logic a bit more.

queryset |= self.filter(
type=EXTERNAL,
project__external_builds_privacy_level=constants.PUBLIC,
)
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little worried about performance here -- we're adding a join and a few more queries on all our super common querysets. Can we not just change this on the external manager instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, maybe, I'll need to take a look at where we are using those managers

objects = VersionManager.from_queryset(VersionQuerySet)()
# Only include BRANCH, TAG, UNKNOWN type Versions.
internal = InternalVersionManager.from_queryset(VersionQuerySet)()
# Only include EXTERNAL type Versions.
external = ExternalVersionManager.from_queryset(VersionQuerySet)()

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can make this happen only when executing objects and external, as the internal manager already filters them out.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have used a partial class to pass a parameter indicating if the manager being used is for internal only versions.

Copy link
Member

@ericholscher ericholscher Jun 24, 2021

Choose a reason for hiding this comment

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

@stsewd It seems like it might be cleaner to put this on a public method in the ExternalVersionManager instead of on the base VersionQueryset, since it only applies there (eg. we only want to run it on Version.external.public, I believe).

We should also do the same logic for the other querier (eg. on the ExternalBuildManager)

Copy link
Member Author

Choose a reason for hiding this comment

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

We also want to include this on the default manager, since we do have calls to Version.objects.public/Build.objects.public.
And I'm not sure about moving these to the manager, these are more filters, and all of our querysets are there, we would nee to move all of those. I was about to use inheritance instead of the partial, but then we need to create three more classes (parent, InternalQuerysetBase, InternalQueryset(SeetingsOverride)) and one more override in .com :/

Copy link
Member

Choose a reason for hiding this comment

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

We don't need to worry about filtering external builds on Version.objects.public though right? They will already be filtered out, regardless of privacy level?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if I understood what you mean 😅.

  • Version.objects.public -> external and internal versions. Internal versions are checked against version.privacy_level, and external versions are checked against project.external_builds_privacy_level.
  • Version.internal.public -> internal versions only, checked against version.privacy_level
  • Version.external.public -> external versions only, checked against project.external_builds_privacy_level (for this case we could omit one filter from the current implementation, I'll do that)

But anyway, Version.objects.public need to check for both external and internal as that manager is expected to include both types of versions.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yea, I was thinking Version.internal.public.

@stsewd stsewd requested a review from ericholscher June 24, 2021 16:19
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This looks good except for my question on the QS.

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

I think this works well -- hopefully it doesn't add much load to the DB.

@stsewd stsewd merged commit e0e6602 into master Jul 1, 2021
@stsewd stsewd deleted the privacy-level-external-versions branch July 1, 2021 15:32
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