Avoid a useless request

This commit is contained in:
emeric
2023-10-21 00:00:36 +02:00
parent d86260ba2d
commit 07f58b3d10
2 changed files with 9 additions and 10 deletions
+4 -4
View File
@@ -152,7 +152,8 @@ namespace API::Subsonic
trackResponse.setAttribute("starred", StringUtils::toISO8601String(dateTime));
// Report the first GENRE for this track
if (ClusterType::pointer genreClusterType{ ClusterType::find(dbSession, "GENRE") })
const ClusterType::pointer genreClusterType{ ClusterType::find(dbSession, "GENRE") };
if (genreClusterType)
{
auto clusters{ track->getClusterGroups({genreClusterType}, 1) };
if (!clusters.empty() && !clusters.front().empty())
@@ -235,12 +236,11 @@ namespace API::Subsonic
{
trackResponse.createEmptyArrayChild("genres");
ClusterType::pointer clusterType{ ClusterType::find(dbSession, "GENRE") };
if (clusterType)
if (genreClusterType)
{
Cluster::FindParameters params;
params.setTrack(track->getId());
params.setClusterType(clusterType->getId());
params.setClusterType(genreClusterType->getId());
for (const ClusterId clusterId : Cluster::find(dbSession, params).results)
{