Added artist tag cloud
This commit is contained in:
@@ -137,7 +137,7 @@ Artist::getByFilter(Wt::Dbo::Session& session,
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<Wt::Dbo::ptr<Release> >
|
||||
std::vector<Wt::Dbo::ptr<Release>>
|
||||
Artist::getReleases(const std::set<id_type>& clusterIds) const
|
||||
{
|
||||
assert(self());
|
||||
@@ -183,6 +183,25 @@ Artist::getReleases(const std::set<id_type>& clusterIds) const
|
||||
return std::vector< Wt::Dbo::ptr<Release> > (res.begin(), res.end());
|
||||
}
|
||||
|
||||
std::vector<Wt::Dbo::ptr<Cluster>>
|
||||
Artist::getClusters(int size) const
|
||||
{
|
||||
assert(self());
|
||||
assert(self()->id() != Wt::Dbo::dbo_traits<Artist>::invalidId() );
|
||||
assert(session());
|
||||
|
||||
Wt::Dbo::Query<Cluster::pointer> query = session()->query<Cluster::pointer>
|
||||
("select c from cluster c INNER JOIN track t ON c.id = t_c.cluster_id INNER JOIN track_cluster t_c ON t_c.track_id = t.id INNER JOIN artist a ON t.artist_id = a.id")
|
||||
.where("a.id = ?").bind(self()->id())
|
||||
.groupBy("c.id")
|
||||
.orderBy("COUNT(c.id) DESC")
|
||||
.limit(size);
|
||||
|
||||
Wt::Dbo::collection<Cluster::pointer> res = query;
|
||||
|
||||
return std::vector<Cluster::pointer>(res.begin(), res.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Database
|
||||
|
||||
@@ -63,9 +63,12 @@ class Artist : public Wt::Dbo::Dbo<Artist>
|
||||
std::string getName(void) const { return _name; }
|
||||
std::string getMBID(void) const { return _MBID; }
|
||||
|
||||
// Get the releases that have at least one track for this artist + belongs to optonal cluster filters
|
||||
// Get the releases that have at least one track for this artist that belongs to optional cluster filters
|
||||
std::vector<Wt::Dbo::ptr<Release>> getReleases(const std::set<id_type>& clusterIds = std::set<id_type>()) const;
|
||||
|
||||
// Get the cluster of the tracks made by this artist
|
||||
std::vector<Wt::Dbo::ptr<Cluster>> getClusters(int size) const;
|
||||
|
||||
void setMBID(std::string mbid) { _MBID = mbid; }
|
||||
|
||||
// Create
|
||||
|
||||
Reference in New Issue
Block a user