API Subsonic: better support, added genre
This commit is contained in:
@@ -73,7 +73,8 @@ Release::getAll(Wt::Dbo::Session& session, boost::optional<std::size_t> offset,
|
||||
{
|
||||
Wt::Dbo::collection<pointer> res = session.find<Release>()
|
||||
.offset(offset ? static_cast<int>(*offset) : -1)
|
||||
.limit(size ? static_cast<int>(*size) : - 1);
|
||||
.limit(size ? static_cast<int>(*size) : - 1)
|
||||
.orderBy("name COLLATE NOCASE");
|
||||
|
||||
return std::vector<pointer>(res.begin(), res.end());
|
||||
}
|
||||
@@ -150,19 +151,28 @@ getQuery(Wt::Dbo::Session& session,
|
||||
return query;
|
||||
}
|
||||
|
||||
std::vector<Release::pointer>
|
||||
Release::getByFilter(Wt::Dbo::Session& session, const std::set<IdType>& clusterIds)
|
||||
{
|
||||
bool moreResults;
|
||||
return getByFilter(session, clusterIds, {}, {}, {}, moreResults);
|
||||
}
|
||||
|
||||
std::vector<Release::pointer>
|
||||
Release::getByFilter(Wt::Dbo::Session& session,
|
||||
const std::set<IdType>& clusterIds,
|
||||
const std::vector<std::string> keywords,
|
||||
int offset, int size, bool& moreResults)
|
||||
boost::optional<std::size_t> offset,
|
||||
boost::optional<std::size_t> size,
|
||||
bool& moreResults)
|
||||
{
|
||||
Wt::Dbo::collection<pointer> collection = getQuery(session, clusterIds, keywords)
|
||||
.limit(size != -1 ? size + 1 : -1)
|
||||
.offset(offset);
|
||||
.limit(size ? static_cast<int>(*size) + 1 : -1)
|
||||
.offset(offset ? static_cast<int>(*offset) : -1);
|
||||
|
||||
auto res = std::vector<pointer>(collection.begin(), collection.end());
|
||||
auto res {std::vector<pointer>(collection.begin(), collection.end())};
|
||||
|
||||
if (size != -1 && res.size() == static_cast<std::size_t>(size) + 1)
|
||||
if (size && res.size() == static_cast<std::size_t>(*size) + 1)
|
||||
{
|
||||
moreResults = true;
|
||||
res.pop_back();
|
||||
|
||||
Reference in New Issue
Block a user