Added release tag cloud
This commit is contained in:
@@ -202,6 +202,4 @@ Artist::getClusters(int size) const
|
||||
return std::vector<Cluster::pointer>(res.begin(), res.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Database
|
||||
|
||||
@@ -225,4 +225,23 @@ Release::getTracks(const std::set<id_type>& clusterIds) const
|
||||
return std::vector< Wt::Dbo::ptr<Track> > (res.begin(), res.end());
|
||||
}
|
||||
|
||||
std::vector<Wt::Dbo::ptr<Cluster>>
|
||||
Release::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 release r ON t.release_id = r.id")
|
||||
.where("r.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
|
||||
|
||||
@@ -57,6 +57,7 @@ class Release : public Wt::Dbo::Dbo<Release>
|
||||
bool& moreExpected);
|
||||
|
||||
std::vector<Wt::Dbo::ptr<Track>> getTracks(const std::set<id_type>& clusters = std::set<id_type>()) const;
|
||||
std::vector<Wt::Dbo::ptr<Cluster>> getClusters(int size) const;
|
||||
|
||||
// Create
|
||||
static pointer create(Wt::Dbo::Session& session, const std::string& name, const std::string& MBID = "");
|
||||
|
||||
@@ -75,14 +75,14 @@ Artist::refresh()
|
||||
t->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
|
||||
auto clusterContainers = new Wt::WContainerWidget();
|
||||
t->bindWidget("tags", clusterContainers);
|
||||
t->bindWidget("clusters", clusterContainers);
|
||||
|
||||
{
|
||||
auto clusters = artist->getClusters(3);
|
||||
|
||||
for (auto cluster : clusters)
|
||||
{
|
||||
auto entry = new Wt::WTemplate(Wt::WString::tr("template-artist-tag-entry"), clusterContainers);
|
||||
auto entry = new Wt::WTemplate(Wt::WString::tr("template-artist-cluster-entry"), clusterContainers);
|
||||
|
||||
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::PlainText);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,20 @@ Release::refresh()
|
||||
cover->setImageLink(Wt::WLink (SessionImageResource()->getReleaseUrl(release.id(), 512)));
|
||||
t->bindWidget("cover", cover);
|
||||
|
||||
auto clusterContainers = new Wt::WContainerWidget();
|
||||
t->bindWidget("clusters", clusterContainers);
|
||||
|
||||
{
|
||||
auto clusters = release->getClusters(3);
|
||||
|
||||
for (auto cluster : clusters)
|
||||
{
|
||||
auto entry = new Wt::WTemplate(Wt::WString::tr("template-release-cluster-entry"), clusterContainers);
|
||||
|
||||
entry->bindString("name", Wt::WString::fromUTF8(cluster->getName()), Wt::PlainText);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto playBtn = new Wt::WText(Wt::WString::tr("btn-release-play-btn"), Wt::XHTMLText);
|
||||
t->bindWidget("play-btn", playBtn);
|
||||
|
||||
Reference in New Issue
Block a user