Avoid a useless request
This commit is contained in:
@@ -124,9 +124,10 @@ namespace API::Subsonic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Report the first GENRE for this track
|
// Report the first GENRE for this track
|
||||||
if (ClusterType::pointer clusterType{ ClusterType::find(dbSession, "GENRE") })
|
const ClusterType::pointer genreClusterType{ ClusterType::find(dbSession, "GENRE") };
|
||||||
|
if (genreClusterType)
|
||||||
{
|
{
|
||||||
auto clusters{ release->getClusterGroups({clusterType}, 1) };
|
auto clusters{ release->getClusterGroups({genreClusterType}, 1) };
|
||||||
if (!clusters.empty() && !clusters.front().empty())
|
if (!clusters.empty() && !clusters.front().empty())
|
||||||
albumNode.setAttribute("genre", clusters.front().front()->getName());
|
albumNode.setAttribute("genre", clusters.front().front()->getName());
|
||||||
}
|
}
|
||||||
@@ -173,13 +174,11 @@ namespace API::Subsonic
|
|||||||
// Genres
|
// Genres
|
||||||
{
|
{
|
||||||
albumNode.createEmptyArrayChild("genres");
|
albumNode.createEmptyArrayChild("genres");
|
||||||
|
if (genreClusterType)
|
||||||
ClusterType::pointer clusterType{ ClusterType::find(dbSession, "GENRE") };
|
|
||||||
if (clusterType)
|
|
||||||
{
|
{
|
||||||
Cluster::FindParameters params;
|
Cluster::FindParameters params;
|
||||||
params.setRelease(release->getId());
|
params.setRelease(release->getId());
|
||||||
params.setClusterType(clusterType->getId());
|
params.setClusterType(genreClusterType->getId());
|
||||||
|
|
||||||
for (const ClusterId clusterId : Cluster::find(dbSession, params).results)
|
for (const ClusterId clusterId : Cluster::find(dbSession, params).results)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ namespace API::Subsonic
|
|||||||
trackResponse.setAttribute("starred", StringUtils::toISO8601String(dateTime));
|
trackResponse.setAttribute("starred", StringUtils::toISO8601String(dateTime));
|
||||||
|
|
||||||
// Report the first GENRE for this track
|
// 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) };
|
auto clusters{ track->getClusterGroups({genreClusterType}, 1) };
|
||||||
if (!clusters.empty() && !clusters.front().empty())
|
if (!clusters.empty() && !clusters.front().empty())
|
||||||
@@ -235,12 +236,11 @@ namespace API::Subsonic
|
|||||||
{
|
{
|
||||||
trackResponse.createEmptyArrayChild("genres");
|
trackResponse.createEmptyArrayChild("genres");
|
||||||
|
|
||||||
ClusterType::pointer clusterType{ ClusterType::find(dbSession, "GENRE") };
|
if (genreClusterType)
|
||||||
if (clusterType)
|
|
||||||
{
|
{
|
||||||
Cluster::FindParameters params;
|
Cluster::FindParameters params;
|
||||||
params.setTrack(track->getId());
|
params.setTrack(track->getId());
|
||||||
params.setClusterType(clusterType->getId());
|
params.setClusterType(genreClusterType->getId());
|
||||||
|
|
||||||
for (const ClusterId clusterId : Cluster::find(dbSession, params).results)
|
for (const ClusterId clusterId : Cluster::find(dbSession, params).results)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user