Commit 8c2fe11c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

IAlbum: Reintroduce a release year

This partially reverts eea25dd3
parent b2d80c26
......@@ -31,6 +31,7 @@ class IAlbum
virtual ~IAlbum() {}
virtual unsigned int id() const = 0;
virtual const std::string& title() const = 0;
virtual time_t releaseYear() const = 0;
virtual const std::string& shortSummary() const = 0;
virtual const std::string& artworkUrl() const = 0;
virtual time_t lastSyncDate() const = 0;
......
......@@ -38,6 +38,7 @@ Album::Album(DBConnection dbConnection, sqlite::Row& row)
row >> m_id
>> m_title
>> m_artistId
>> m_releaseYear
>> m_shortSummary
>> m_artworkUrl
>> m_lastSyncDate
......@@ -48,6 +49,7 @@ Album::Album(const std::string& title )
: m_id( 0 )
, m_title( title )
, m_artistId( 0 )
, m_releaseYear( 0 )
, m_lastSyncDate( 0 )
, m_nbTracks( 0 )
, m_tracksCached( false )
......@@ -64,6 +66,21 @@ const std::string& Album::title() const
return m_title;
}
time_t Album::releaseYear() const
{
return m_releaseYear;
}
bool Album::setReleaseYear( time_t date )
{
static const std::string req = "UPDATE " + policy::AlbumTable::Name
+ " SET release_year = ? WHERE id_album = ?";
if ( sqlite::Tools::executeUpdate( m_dbConnection, req, date, m_id ) == false )
return false;
m_releaseYear = date;
return true;
}
const std::string& Album::shortSummary() const
{
return m_shortSummary;
......@@ -198,6 +215,7 @@ bool Album::createTable(DBConnection dbConnection )
"id_album INTEGER PRIMARY KEY AUTOINCREMENT,"
"title TEXT,"
"artist_id UNSIGNED INTEGER,"
"release_year UNSIGNED INTEGER,"
"short_summary TEXT,"
"artwork_url TEXT,"
"last_sync_date UNSIGNED INTEGER,"
......
......@@ -57,6 +57,8 @@ class Album : public IAlbum, public Cache<Album, IAlbum, policy::AlbumTable>
virtual unsigned int id() const override;
virtual const std::string& title() const override;
virtual time_t releaseYear() const override;
bool setReleaseYear( time_t date );
virtual const std::string& shortSummary() const override;
bool setShortSummary( const std::string& summary );
virtual const std::string& artworkUrl() const override;
......@@ -81,6 +83,7 @@ class Album : public IAlbum, public Cache<Album, IAlbum, policy::AlbumTable>
unsigned int m_id;
std::string m_title;
unsigned int m_artistId;
unsigned int m_releaseYear;
std::string m_shortSummary;
std::string m_artworkUrl;
time_t m_lastSyncDate;
......
......@@ -111,6 +111,19 @@ TEST_F( Albums, SetGenre )
ASSERT_EQ( t->genre(), t2->albumTrack()->genre() );
}
TEST_F( Albums, SetReleaseDate )
{
auto a = ml->createAlbum( "album" );
a->setReleaseYear( 1234 );
ASSERT_EQ( a->releaseYear(), 1234 );
Reload();
auto a2 = ml->album( a->id() );
ASSERT_EQ( a->releaseYear(), a2->releaseYear() );
}
TEST_F( Albums, SetShortSummary )
{
auto a = ml->createAlbum( "album" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment