[UI/MOBILE] Handling year in release

This commit is contained in:
emeric
2015-11-22 15:01:00 +01:00
parent fc88cce33e
commit 963e5911e3
4 changed files with 41 additions and 14 deletions
+24
View File
@@ -140,4 +140,28 @@ Release::getByFilter(Wt::Dbo::Session& session, SearchFilter filter, int offset,
return std::vector<pointer>(res.begin(), res.end());
}
int
Release::getReleaseYear(bool original) const
{
assert(session());
// TODO something better
auto tracks = Track::getByFilter(*session(), SearchFilter::ById(SearchFilter::Field::Release, this->id()), -1, 1);
if (tracks.empty())
return 0;
boost::gregorian::date date;
if (original)
date = tracks.front()->getOriginalDate().date();
else
date = tracks.front()->getDate().date();
if (date.is_special())
return 0;
return date.year();
}
} // namespace Database
+3
View File
@@ -53,6 +53,9 @@ class Release : public Wt::Dbo::Dbo<Release>
// Create
static pointer create(Wt::Dbo::Session& session, const std::string& name, const std::string& MBID = "");
// Utility functions
int getReleaseYear(bool originalDate = false) const; // 0 if unknown or various
// MVC models for the user interface
// ID, Release name, year, track counts
typedef boost::tuple<id_type, std::string, boost::posix_time::ptime, int> UIQueryResult;