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

Add Ratings database service. #3603

Merged
merged 2 commits into from Apr 23, 2024
Merged

Conversation

demiankatz
Copy link
Member

More backporting from #2233.

if (is_int($resource)) {
$resource = $this->getDbTable('resource')->select(['id' => $resource])->current();
}
return $resource->addOrUpdateRating(is_int($user) ? $user : $user->getId(), $rating);
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 realize that addOrUpdateRating is not defined in ResourceEntityInterface. This discrepancy is only necessary as a stopgap until we get to the new code in #2233. It should be safe in the meantime.

@@ -252,8 +252,10 @@ public function getRatingData(?int $userId = null)
// Cache data since comments list may ask for same information repeatedly:
$cacheKey = $userId ?? '-';
if (!isset($this->ratingCache[$cacheKey])) {
$table = $this->getDbTable('Ratings');
$this->ratingCache[$cacheKey] = $table->getForResource(
$ratingsService = $this->getDbService(
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 would definitely like to decouple ratings logic from record drivers, similar to what I'd like to do for comments... but one step at a time! :-)

@demiankatz demiankatz added this to the 10.0 milestone Apr 19, 2024
@demiankatz demiankatz added the architecture pull requests that involve significant refactoring / architectural changes label Apr 19, 2024
@demiankatz demiankatz removed the request for review from EreMaijala April 23, 2024 17:50
@demiankatz demiankatz merged commit 2c24e28 into vufind-org:dev Apr 23, 2024
7 checks passed
@demiankatz demiankatz deleted the ratings-service branch April 23, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture pull requests that involve significant refactoring / architectural changes
Projects
None yet
2 participants