-
Notifications
You must be signed in to change notification settings - Fork 675
Added constants for search API #1131
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
Conversation
gitlab/const.py
Outdated
| SEARCH_SCOPE_GLOBAL_BLOBS = _SEARCH_SCOPE_BLOBS | ||
| SEARCH_SCOPE_GLOBAL_USERS = _SEARCH_SCOPE_USERS | ||
|
|
||
| SEARCH_SCOPE_GROUP_PROJECTS = _SEARCH_SCOPE_PROJECTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the duplication needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you mean with duplication? There is a search scope for:
globalgroupproject
These three scopes have similar criteria in which you can search, but not 100% the same. Those string literals that collide are extracted into a "private" field.
One could also do something like:
SEARCH_SCOPE_PROJECTS = "projects"
SEARCH_SCOPE_ISSUES = "issues"
SEARCH_SCOPE_MERGE_REQUESTS = "merge_requests"
SEARCH_SCOPE_MILESTONES = "milestones"
SEARCH_SCOPE_WIKI_BLOBS = "wiki_blobs"
SEARCH_SCOPE_COMMITS = "commits"
SEARCH_SCOPE_BLOBS = "blobs"
SEARCH_SCOPE_USERS = "users"
SEARCH_SCOPE_SNIPPET_TITLES = "snippet_titles"
SEARCH_SCOPE_NOTES = "notes"But that would not allow you to see that the SEARCH_SCOPE_SNIPPET_TITLES only applies to the GLOBAL scope. Same story for the SEARCH_SCOPE_NOTES which only applies to projects scope.
I guess my entire code could be replaced with (now that I think about it while typing):
# all scopes (global, group and project)
SEARCH_SCOPE_PROJECTS = "projects"
SEARCH_SCOPE_ISSUES = "issues"
SEARCH_SCOPE_MERGE_REQUESTS = "merge_requests"
SEARCH_SCOPE_MILESTONES = "milestones"
SEARCH_SCOPE_WIKI_BLOBS = "wiki_blobs"
SEARCH_SCOPE_COMMITS = "commits"
SEARCH_SCOPE_BLOBS = "blobs"
SEARCH_SCOPE_USERS = "users"
# global scope
SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES = "snippet_titles"
# project scope
SEARCH_SCOPE_PROJECT_NOTES = "notes"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, +1 vote for this approach, I like your last suggestion in this comment, it's much more concise than in the original commit :)
|
Thanks for the MR! Just a question. |
|
@max-wittig, any updates on this matter? |
|
Hey @valentingregoire! Sorry for the delay! Could you maybe add some docs why or how those variables should be used? |
valentingregoire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @valentingregoire! Sorry for the delay! Could you maybe add some docs why or how those variables should be used?
@max-wittig, I have added documentation (and fixed a typo in the meantime).
gitlab/const.py
Outdated
| SEARCH_SCOPE_GLOBAL_BLOBS = _SEARCH_SCOPE_BLOBS | ||
| SEARCH_SCOPE_GLOBAL_USERS = _SEARCH_SCOPE_USERS | ||
|
|
||
| SEARCH_SCOPE_GROUP_PROJECTS = _SEARCH_SCOPE_PROJECTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you mean with duplication? There is a search scope for:
globalgroupproject
These three scopes have similar criteria in which you can search, but not 100% the same. Those string literals that collide are extracted into a "private" field.
One could also do something like:
SEARCH_SCOPE_PROJECTS = "projects"
SEARCH_SCOPE_ISSUES = "issues"
SEARCH_SCOPE_MERGE_REQUESTS = "merge_requests"
SEARCH_SCOPE_MILESTONES = "milestones"
SEARCH_SCOPE_WIKI_BLOBS = "wiki_blobs"
SEARCH_SCOPE_COMMITS = "commits"
SEARCH_SCOPE_BLOBS = "blobs"
SEARCH_SCOPE_USERS = "users"
SEARCH_SCOPE_SNIPPET_TITLES = "snippet_titles"
SEARCH_SCOPE_NOTES = "notes"But that would not allow you to see that the SEARCH_SCOPE_SNIPPET_TITLES only applies to the GLOBAL scope. Same story for the SEARCH_SCOPE_NOTES which only applies to projects scope.
I guess my entire code could be replaced with (now that I think about it while typing):
# all scopes (global, group and project)
SEARCH_SCOPE_PROJECTS = "projects"
SEARCH_SCOPE_ISSUES = "issues"
SEARCH_SCOPE_MERGE_REQUESTS = "merge_requests"
SEARCH_SCOPE_MILESTONES = "milestones"
SEARCH_SCOPE_WIKI_BLOBS = "wiki_blobs"
SEARCH_SCOPE_COMMITS = "commits"
SEARCH_SCOPE_BLOBS = "blobs"
SEARCH_SCOPE_USERS = "users"
# global scope
SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES = "snippet_titles"
# project scope
SEARCH_SCOPE_PROJECT_NOTES = "notes"|
@max-wittig, any updates? |
|
All good 👍 |
I added some constants for the search API. I used the official search API docs as reference: https://docs.gitlab.com/ee/api/search.html#project-search-api
It's always nice to be able to link to existing constants instead of having to manually foresee strings.