Make filters really work

This commit is contained in:
emeric
2018-02-05 13:39:45 +01:00
parent 1e470a34b1
commit cea01d06b7
14 changed files with 187 additions and 18 deletions
+3 -3
View File
@@ -91,7 +91,7 @@ Artist::getAllOrphans(Wt::Dbo::Session& session)
static
Wt::Dbo::Query<Artist::pointer>
getQuery(Wt::Dbo::Session& session,
const std::vector<id_type>& clusterIds,
const std::set<id_type>& clusterIds,
const std::vector<std::string>& keywords)
{
WhereClause where;
@@ -132,7 +132,7 @@ getQuery(Wt::Dbo::Session& session,
std::vector<Artist::pointer>
Artist::getByFilter(Wt::Dbo::Session& session,
const std::vector<id_type>& clusters,
const std::set<id_type>& clusters,
const std::vector<std::string> keywords,
int offset, int size, bool& moreResults)
{
@@ -152,7 +152,7 @@ Artist::getByFilter(Wt::Dbo::Session& session,
}
std::vector<Wt::Dbo::ptr<Release> >
Artist::getReleases(const std::vector<id_type>& clusterIds) const
Artist::getReleases(const std::set<id_type>& clusterIds) const
{
assert(self());
assert(self()->id() != Wt::Dbo::dbo_traits<Artist>::invalidId() );
+2 -2
View File
@@ -51,7 +51,7 @@ class Artist : public Wt::Dbo::Dbo<Artist>
static pointer getNone(Wt::Dbo::Session& session); // Special entry
static std::vector<pointer> getByName(Wt::Dbo::Session& session, const std::string& name);
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::vector<id_type>& clusters, // at least one track that belongs to these clusters
const std::set<id_type>& clusters, // at least one track that belongs to these clusters
const std::vector<std::string> keywords, // name must match all of these keywords
int offset,
int size,
@@ -65,7 +65,7 @@ class Artist : public Wt::Dbo::Dbo<Artist>
std::string getMBID(void) const { return _MBID; }
// Get the releases that have at least one track for this artist + belongs to optonal cluster filters
std::vector<Wt::Dbo::ptr<Release>> getReleases(const std::vector<id_type>& clusterIds = std::vector<id_type>()) const;
std::vector<Wt::Dbo::ptr<Release>> getReleases(const std::set<id_type>& clusterIds = std::set<id_type>()) const;
void setMBID(std::string mbid) { _MBID = mbid; }
+3 -3
View File
@@ -90,7 +90,7 @@ Release::getAllOrphans(Wt::Dbo::Session& session)
static
Wt::Dbo::Query<Release::pointer>
getQuery(Wt::Dbo::Session& session,
const std::vector<id_type>& clusterIds,
const std::set<id_type>& clusterIds,
const std::vector<std::string> keywords)
{
WhereClause where;
@@ -130,7 +130,7 @@ getQuery(Wt::Dbo::Session& session,
std::vector<Release::pointer>
Release::getByFilter(Wt::Dbo::Session& session,
const std::vector<id_type>& clusterIds,
const std::set<id_type>& clusterIds,
const std::vector<std::string> keywords,
int offset, int size, bool& moreResults)
{
@@ -195,7 +195,7 @@ Release::hasVariousArtists() const
}
std::vector<Wt::Dbo::ptr<Track>>
Release::getTracks(const std::vector<id_type>& clusterIds) const
Release::getTracks(const std::set<id_type>& clusterIds) const
{
assert(self());
assert(self()->id() != Wt::Dbo::dbo_traits<Release>::invalidId() );
+2 -2
View File
@@ -51,13 +51,13 @@ class Release : public Wt::Dbo::Dbo<Release>
static std::vector<pointer> getAll(Wt::Dbo::Session& session, int offset, int size);
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::vector<id_type>& clusters, // at least one track that belongs to these clusters
const std::set<id_type>& clusters, // at least one track that belongs to these clusters
const std::vector<std::string> keywords, // name must match all of these keywords
int offset,
int size,
bool& moreExpected);
std::vector<Wt::Dbo::ptr<Track>> getTracks(const std::vector<id_type>& clusters = std::vector<id_type>()) const;
std::vector<Wt::Dbo::ptr<Track>> getTracks(const std::set<id_type>& clusters = std::set<id_type>()) const;
// Create
static pointer create(Wt::Dbo::Session& session, const std::string& name, const std::string& MBID = "");
+11 -2
View File
@@ -111,7 +111,7 @@ Track::getClusters(void) const
static
Wt::Dbo::Query< Track::pointer >
getQuery(Wt::Dbo::Session& session,
const std::vector<id_type>& clusterIds,
const std::set<id_type>& clusterIds,
const std::vector<std::string> keywords)
{
WhereClause where;
@@ -165,7 +165,7 @@ Track::getStats(Wt::Dbo::Session& session, SearchFilter filter)
std::vector<Track::pointer>
Track::getByFilter(Wt::Dbo::Session& session,
const std::vector<id_type>& clusterIds,
const std::set<id_type>& clusterIds,
const std::vector<std::string> keywords,
int offset, int size, bool& moreResults)
{
@@ -282,6 +282,15 @@ Cluster::getQuery(Wt::Dbo::Session& session, SearchFilter filter)
return query;
}
std::vector<std::string>
Cluster::getAllTypes(Wt::Dbo::Session& session)
{
Wt::Dbo::collection<std::string> res
= session.query<std::string>("SELECT type from cluster").groupBy("type").orderBy("type");
return std::vector<std::string>(res.begin(), res.end());
}
std::vector<Cluster::pointer>
Cluster::getByFilter(Wt::Dbo::Session& session, SearchFilter filter, int offset, int size)
{
+2 -1
View File
@@ -62,6 +62,7 @@ class Cluster
static pointer getNone(Wt::Dbo::Session& session);
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session, SearchFilter filter, int offset = -1, int size = -1);
static Wt::Dbo::collection<pointer> getAll(Wt::Dbo::Session& session);
static std::vector<std::string> getAllTypes(Wt::Dbo::Session& session);
static std::vector<pointer> getByType(Wt::Dbo::Session& session, std::string type);
// Create utility
@@ -120,7 +121,7 @@ class Track
static pointer getById(Wt::Dbo::Session& session, id_type id);
static pointer getByMBID(Wt::Dbo::Session& session, const std::string& MBID);
static std::vector<pointer> getByFilter(Wt::Dbo::Session& session,
const std::vector<id_type>& clusters, // tracks that belong to these clusters
const std::set<id_type>& clusters, // tracks that belong to these clusters
const std::vector<std::string> keywords, // name must match all of these keywords
int offset,
int size,