Commit 898b760c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Album: Make it clear that we expose a year, not a date

parent c13e5fe4
......@@ -31,7 +31,7 @@ class IAlbum
virtual ~IAlbum() {}
virtual unsigned int id() const = 0;
virtual const std::string& title() const = 0;
virtual time_t releaseDate() 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;
......
......@@ -36,7 +36,7 @@ Album::Album(DBConnection dbConnection, sqlite::Row& row)
{
row >> m_id
>> m_title
>> m_releaseDate
>> m_releaseYear
>> m_shortSummary
>> m_artworkUrl
>> m_lastSyncDate
......@@ -46,7 +46,7 @@ Album::Album(DBConnection dbConnection, sqlite::Row& row)
Album::Album(const std::string& title )
: m_id( 0 )
, m_title( title )
, m_releaseDate( 0 )
, m_releaseYear( 0 )
, m_lastSyncDate( 0 )
, m_nbTracks( 0 )
{
......@@ -62,18 +62,18 @@ const std::string& Album::title() const
return m_title;
}
time_t Album::releaseDate() const
time_t Album::releaseYear() const
{
return m_releaseDate;
return m_releaseYear;
}
bool Album::setReleaseDate( time_t date )
bool Album::setReleaseYear( time_t date )
{
static const std::string req = "UPDATE " + policy::AlbumTable::Name
+ " SET release_date = ? WHERE id_album = ?";
+ " SET release_year = ? WHERE id_album = ?";
if ( sqlite::Tools::executeUpdate( m_dbConnection, req, date, m_id ) == false )
return false;
m_releaseDate = date;
m_releaseYear = date;
return true;
}
......@@ -168,7 +168,7 @@ bool Album::createTable(DBConnection dbConnection )
"("
"id_album INTEGER PRIMARY KEY AUTOINCREMENT,"
"title TEXT UNIQUE ON CONFLICT FAIL,"
"release_date UNSIGNED INTEGER,"
"release_year UNSIGNED INTEGER,"
"short_summary TEXT,"
"artwork_url TEXT,"
"last_sync_date UNSIGNED INTEGER,"
......
......@@ -56,8 +56,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 releaseDate() const override;
bool setReleaseDate( time_t date );
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;
......@@ -77,7 +77,7 @@ class Album : public IAlbum, public Cache<Album, IAlbum, policy::AlbumTable>
DBConnection m_dbConnection;
unsigned int m_id;
std::string m_title;
unsigned int m_releaseDate;
unsigned int m_releaseYear;
std::string m_shortSummary;
std::string m_artworkUrl;
time_t m_lastSyncDate;
......
......@@ -141,7 +141,7 @@ bool VLCMetadataService::parseAudioFile( std::shared_ptr<Media> media, VLC::Medi
newAlbum = true;
auto date = vlcMedia.meta( libvlc_meta_Date );
if ( date.length() > 0 )
album->setReleaseDate( std::stoul( date ) );
album->setReleaseYear( std::stoul( date ) );
auto artwork = vlcMedia.meta( libvlc_meta_ArtworkURL );
if ( artwork.length() != 0 )
album->setArtworkUrl( artwork );
......
......@@ -114,13 +114,13 @@ TEST_F( Albums, SetReleaseDate )
{
auto a = ml->createAlbum( "album" );
a->setReleaseDate( 1234 );
ASSERT_EQ( a->releaseDate(), 1234 );
a->setReleaseYear( 1234 );
ASSERT_EQ( a->releaseYear(), 1234 );
Reload();
auto a2 = ml->album( "album" );
ASSERT_EQ( a->releaseDate(), a2->releaseDate() );
ASSERT_EQ( a->releaseYear(), a2->releaseYear() );
}
TEST_F( Albums, SetShortSummary )
......
......@@ -120,8 +120,8 @@ TEST_F( VLCMetadataServices, ParseAlbum )
ASSERT_EQ( album->title(), "Boys for Pele" );
// ASSERT_NE( album->artworkUrl().length(), 0u );
auto releaseDate = album->releaseDate();
ASSERT_NE( releaseDate, 0 );
auto releaseYear = album->releaseYear();
ASSERT_NE( releaseYear, 0 );
auto album2 = ml->album( "Boys for Pele" );
ASSERT_EQ( album, album2 );
......
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