Change GetUsersFromProject to only return arrays#1619
Merged
Conversation
39af129 to
ed5866c
Compare
Comment on lines
+302
to
+305
| return DB::table('coveragefilepriority') | ||
| ->join('coveragefile2user', 'coveragefilepriority.id', '=', 'coveragefile2user.fileid') | ||
| ->where('coveragefilepriority.projectid', '=', intval($this->ProjectId)) | ||
| ->pluck('userid')->toArray(); |
Collaborator
There was a problem hiding this comment.
Do we need to add a DISTINCT clause to this query to reduce the size of the result array? It's in the original query, but I'm not sure if it's necessary or not.
| * @return array<int> | ||
| */ | ||
| public function GetUsersFromProject(): array|false | ||
| public function GetUsersFromProject(): array |
Collaborator
There was a problem hiding this comment.
This function is only used in one location, and this change makes the function rather trivial. The query doesn't even really relate to this model anyway...
Would it make sense to just eliminate this function and inline the contents?
When there are no users linked to a project coverage file, the GetUsersFromProject function returns false, assuming that an empty query_result means an error. Returning false created a 500 error when the caller function attempted to loop over the return. Since it is called in one place only, remove the function and set the DB call in the controller directly.
ed5866c to
41a5836
Compare
williamjallen
approved these changes
Aug 7, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When there are no users linked to a project coverage file, the GetUsersFromProject function returns false, assuming that an empty query_result means an error. Returning false created a 500 error when the caller function attempted to loop over the return.
Change the function to use Laravel's query system and eliminate the places where boolean values were returned.