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

Move more provider access methods to store #2911

Merged
merged 2 commits into from
Apr 3, 2024
Merged

Conversation

dmjb
Copy link
Contributor

@dmjb dmjb commented Apr 2, 2024

Relates to #2845

Migrate more queries for providers to ProviderStore. This will make it easier to refactor away direct access to the provider table in subequent PRs.

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes #(related issue)

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@dmjb dmjb force-pushed the provider-store-more-methods branch 2 times, most recently from 42fbc17 to f258eb5 Compare April 2, 2024 15:46
@dmjb dmjb marked this pull request as ready for review April 2, 2024 15:47
@dmjb dmjb requested a review from a team as a code owner April 2, 2024 15:47
@coveralls
Copy link

coveralls commented Apr 2, 2024

Coverage Status

coverage: 47.361% (+0.01%) from 47.348%
when pulling ee5a53e on provider-store-more-methods
into 6f69727 on main.

Name: dbRepo.Provider,
Projects: ph,
})
prov, err := s.providerStore.GetByName(ctx, dbRepo.ProjectID, dbRepo.Provider)
Copy link
Contributor

Choose a reason for hiding this comment

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

Genuine question: The old code was calling GetParentProjects and then getting the provider by name in parent. The new code goes to GetByName, which calls findProjects which calls getProjectHierarchy. Are those equivalent?

Copy link
Contributor Author

@dmjb dmjb Apr 2, 2024

Choose a reason for hiding this comment

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

getProjectHierarchy also calls GetParentProjects. In fact, I may get rid of the separate getProjectHierarchy function since it's only called in one places (originally in this branch it was called in a second place too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That being said - one important difference is that the GetByName will check to see if there are any duplicate results and return an error if there is ambiguity about being what is returned, whereas the code I have replaced will not (see the implementation of GetByName).

@eleftherias - since I think you wrote this code: is there any possibility that the original query could match more than one provider?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is possible, but only in a strange corner case where someone renamed their GitHub organization to have the same name as a GitHub organization that they previously installed Minder on. We generally don't handle renames yet, so I think we can ignore that case for now.

dmjb added 2 commits April 3, 2024 10:49
Relates to #2845

Migrate more queries for providers to ProviderStore. This will make it
easier to refactor away direct access to the provider table in subequent
PRs.
@dmjb dmjb force-pushed the provider-store-more-methods branch from e72b3e9 to ee5a53e Compare April 3, 2024 09:49
@dmjb dmjb merged commit a9d3540 into main Apr 3, 2024
19 checks passed
@dmjb dmjb deleted the provider-store-more-methods branch April 3, 2024 10:27
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.

4 participants