Use the scrobbling service to get listen count rathen than querying the db directly

This commit is contained in:
emeric
2023-11-26 17:28:15 +01:00
parent d9c5072479
commit 74a222ed54
10 changed files with 57 additions and 21 deletions
+1 -2
View File
@@ -21,7 +21,6 @@
#include "services/database/Artist.hpp"
#include "services/database/Cluster.hpp"
#include "services/database/Listen.hpp"
#include "services/database/Release.hpp"
#include "services/database/User.hpp"
#include "services/feedback/IFeedbackService.hpp"
@@ -125,7 +124,7 @@ namespace API::Subsonic
}
}
albumNode.setAttribute("playCount", Listen::getCount(context.dbSession, user->getId(), user->getScrobblingBackend(), release->getId()));
albumNode.setAttribute("playCount", Service<Scrobbling::IScrobblingService>::get()->getCount(user->getId(), release->getId()));
// Report the first GENRE for this track
const ClusterType::pointer genreClusterType{ ClusterType::find(context.dbSession, "GENRE") };
+1 -2
View File
@@ -24,7 +24,6 @@
#include "av/IAudioFile.hpp"
#include "services/database/Artist.hpp"
#include "services/database/Cluster.hpp"
#include "services/database/Listen.hpp"
#include "services/database/Release.hpp"
#include "services/database/Track.hpp"
#include "services/database/TrackArtistLink.hpp"
@@ -108,7 +107,7 @@ namespace API::Subsonic
trackResponse.setAttribute("discNumber", *track->getDiscNumber());
if (track->getYear())
trackResponse.setAttribute("year", *track->getYear());
trackResponse.setAttribute("playCount", Listen::getCount(context.dbSession, user->getId(), user->getScrobblingBackend(), track->getId()));
trackResponse.setAttribute("playCount", Service<Scrobbling::IScrobblingService>::get()->getCount(user->getId(), track->getId()));
trackResponse.setAttribute("path", getTrackPath(track));
{
// TODO, store this in DB