Subsonic API : added getByYear in getAlbumList
This commit is contained in:
@@ -836,6 +836,13 @@ handleGetAlbumListRequestCommon(const RequestContext& context, bool id3)
|
|||||||
{
|
{
|
||||||
releases = Release::getAll(context.dbSession, offset, size);
|
releases = Release::getAll(context.dbSession, offset, size);
|
||||||
}
|
}
|
||||||
|
else if (type == "byYear")
|
||||||
|
{
|
||||||
|
int fromYear {getMandatoryParameterAs<int>(context.parameters, "fromYear")};
|
||||||
|
int toYear {getMandatoryParameterAs<int>(context.parameters, "toYear")};
|
||||||
|
|
||||||
|
releases = Release::getByYear(context.dbSession, fromYear, toYear, offset, size);
|
||||||
|
}
|
||||||
else if (type == "byGenre")
|
else if (type == "byGenre")
|
||||||
{
|
{
|
||||||
// Mandatory param
|
// Mandatory param
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ Release::getAllOrphans(Session& session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Release::pointer>
|
std::vector<Release::pointer>
|
||||||
Release::getLastAdded(Session& session, Wt::WDateTime after, boost::optional<std::size_t> offset, boost::optional<std::size_t> limit)
|
Release::getLastAdded(Session& session, const Wt::WDateTime& after, boost::optional<std::size_t> offset, boost::optional<std::size_t> limit)
|
||||||
{
|
{
|
||||||
session.checkSharedLocked();
|
session.checkSharedLocked();
|
||||||
|
|
||||||
@@ -133,6 +133,20 @@ Release::getLastAdded(Session& session, Wt::WDateTime after, boost::optional<std
|
|||||||
return std::vector<pointer>(res.begin(), res.end());
|
return std::vector<pointer>(res.begin(), res.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Release::pointer>
|
||||||
|
Release::getByYear(Session& session, int yearFrom, int yearTo, boost::optional<std::size_t> offset, boost::optional<std::size_t> limit)
|
||||||
|
{
|
||||||
|
Wt::Dbo::collection<Release::pointer> res = session.getDboSession().query<Release::pointer>
|
||||||
|
("SELECT DISTINCT r from release r INNER JOIN track t ON r.id = t.release_id")
|
||||||
|
.where("t.year >= ?").bind(yearFrom)
|
||||||
|
.where("t.year <= ?").bind(yearTo)
|
||||||
|
.orderBy("t.year, r.name COLLATE NOCASE")
|
||||||
|
.offset(offset ? static_cast<int>(*offset) : -1)
|
||||||
|
.limit(limit ? static_cast<int>(*limit) : -1);
|
||||||
|
|
||||||
|
return std::vector<pointer>(res.begin(), res.end());
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
Wt::Dbo::Query<Release::pointer>
|
Wt::Dbo::Query<Release::pointer>
|
||||||
getQuery(Session& session,
|
getQuery(Session& session,
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ class Release : public Wt::Dbo::Dbo<Release>
|
|||||||
static std::vector<pointer> getAllOrphans(Session& session); // no track related
|
static std::vector<pointer> getAllOrphans(Session& session); // no track related
|
||||||
static std::vector<pointer> getAll(Session& session, boost::optional<std::size_t> offset = {}, boost::optional<std::size_t> size = {});
|
static std::vector<pointer> getAll(Session& session, boost::optional<std::size_t> offset = {}, boost::optional<std::size_t> size = {});
|
||||||
static std::vector<pointer> getAllRandom(Session& session, boost::optional<std::size_t> size = {});
|
static std::vector<pointer> getAllRandom(Session& session, boost::optional<std::size_t> size = {});
|
||||||
static std::vector<pointer> getLastAdded(Session& session, Wt::WDateTime after, boost::optional<std::size_t> offset = {}, boost::optional<std::size_t> size = {});
|
static std::vector<pointer> getLastAdded(Session& session, const Wt::WDateTime& after, boost::optional<std::size_t> offset = {}, boost::optional<std::size_t> size = {});
|
||||||
|
static std::vector<pointer> getByYear(Session& session, int yearFrom, int yearTo, boost::optional<std::size_t> offset = {}, boost::optional<std::size_t> size = {});
|
||||||
|
|
||||||
static std::vector<pointer> getByFilter(Session& session, const std::set<IdType>& clusters);
|
static std::vector<pointer> getByFilter(Session& session, const std::set<IdType>& clusters);
|
||||||
static std::vector<pointer> getByFilter(Session& session,
|
static std::vector<pointer> getByFilter(Session& session,
|
||||||
|
|||||||
Reference in New Issue
Block a user