Better radio mode
This commit is contained in:
@@ -74,6 +74,19 @@ Cluster::getTracks(int offset, int limit) const
|
||||
return std::vector<Wt::Dbo::ptr<Track>>(res.begin(), res.end());
|
||||
}
|
||||
|
||||
std::set<IdType>
|
||||
Cluster::getTrackIds() const
|
||||
{
|
||||
assert(session());
|
||||
assert(IdIsValid(self()->id()));
|
||||
|
||||
Wt::Dbo::collection<IdType> res = session()->query<IdType>("SELECT t_c.track_id from track_cluster t_c INNER JOIN cluster c ON c.id = t_c.cluster_id")
|
||||
.where("c.id = ?").bind(self()->id());
|
||||
|
||||
return std::set<IdType>(res.begin(), res.end());
|
||||
|
||||
}
|
||||
|
||||
|
||||
ClusterType::ClusterType(std::string name)
|
||||
: _name(name)
|
||||
|
||||
@@ -52,9 +52,9 @@ class Cluster : public Wt::Dbo::Dbo<Cluster>
|
||||
// Accessors
|
||||
const std::string& getName(void) const { return _name; }
|
||||
Wt::Dbo::ptr<ClusterType> getType() const { return _clusterType; }
|
||||
const Wt::Dbo::collection<Wt::Dbo::ptr<Track>>& getTracks() const { return _tracks; }
|
||||
std::size_t getTrackCount() const { return _tracks.size(); }
|
||||
std::size_t getCount() const { return _tracks.size(); }
|
||||
std::vector<Wt::Dbo::ptr<Track>> getTracks(int offset, int limit) const;
|
||||
std::set<IdType> getTrackIds() const;
|
||||
|
||||
void addTrack(Wt::Dbo::ptr<Track> track);
|
||||
|
||||
|
||||
@@ -155,10 +155,24 @@ Playlist::hasTrack(IdType trackId) const
|
||||
assert(IdIsValid(self()->id()));
|
||||
|
||||
Wt::Dbo::collection<PlaylistEntry::pointer> res = session()->query<PlaylistEntry::pointer>("SELECT p_e from playlist_entry p_e INNER JOIN playlist p ON p_e.playlist_id = p.id")
|
||||
.where("p_e.track_id = ?").bind(trackId);
|
||||
.where("p_e.track_id = ?").bind(trackId)
|
||||
.where("p.id = ?").bind(self()->id());
|
||||
|
||||
return res.size() > 0;
|
||||
}
|
||||
|
||||
std::vector<IdType>
|
||||
Playlist::getTrackIds() const
|
||||
{
|
||||
assert(session());
|
||||
assert(IdIsValid(self()->id()));
|
||||
|
||||
Wt::Dbo::collection<IdType> res = session()->query<IdType>("SELECT p_e.track_id from playlist_entry p_e INNER JOIN playlist p ON p_e.playlist_id = p.id")
|
||||
.where("p.id = ?").bind(self()->id());
|
||||
|
||||
return std::vector<IdType>(res.begin(), res.end());
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace Database
|
||||
|
||||
@@ -58,6 +58,7 @@ class Playlist : public Wt::Dbo::Dbo<Playlist>
|
||||
std::size_t getCount() const;
|
||||
Wt::Dbo::ptr<PlaylistEntry> getEntry(std::size_t pos) const;
|
||||
std::vector<Wt::Dbo::ptr<PlaylistEntry>> getEntries(int offset, int size, bool& moreResults) const;
|
||||
std::vector<IdType> getTrackIds() const;
|
||||
|
||||
// Get clusters, order by occurence
|
||||
std::vector<Wt::Dbo::ptr<Cluster>> getClusters() const;
|
||||
|
||||
Reference in New Issue
Block a user