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

IShow: Return episodes as IMedia

parent 62521d88
...@@ -38,7 +38,7 @@ class IShow ...@@ -38,7 +38,7 @@ class IShow
virtual const std::string& shortSummary() const = 0; virtual const std::string& shortSummary() const = 0;
virtual const std::string& artworkMrl() const = 0; virtual const std::string& artworkMrl() const = 0;
virtual const std::string& tvdbId() const = 0; virtual const std::string& tvdbId() const = 0;
virtual Query<IShowEpisode> episodes( const QueryParameters* params = nullptr ) const = 0; virtual Query<IMedia> episodes( const QueryParameters* params = nullptr ) const = 0;
virtual uint32_t nbSeasons() const = 0; virtual uint32_t nbSeasons() const = 0;
virtual uint32_t nbEpisodes() const = 0; virtual uint32_t nbEpisodes() const = 0;
}; };
......
...@@ -137,10 +137,10 @@ std::shared_ptr<ShowEpisode> Show::addEpisode( Media& media, unsigned int episod ...@@ -137,10 +137,10 @@ std::shared_ptr<ShowEpisode> Show::addEpisode( Media& media, unsigned int episod
return episode; return episode;
} }
Query<IShowEpisode> Show::episodes( const QueryParameters* params ) const Query<IMedia> Show::episodes( const QueryParameters* params ) const
{ {
std::string req = "FROM " + policy::ShowEpisodeTable::Name + " ep " std::string req = "FROM " + policy::MediaTable::Name + " med "
" INNER JOIN " + policy::MediaTable::Name + " med ON ep.media_id = med.id_media " " INNER JOIN " + policy::ShowEpisodeTable::Name + " ep ON ep.media_id = med.id_media "
+ " WHERE ep.show_id = ? ORDER BY "; + " WHERE ep.show_id = ? ORDER BY ";
auto sort = params != nullptr ? params->sort : SortingCriteria::Default; auto sort = params != nullptr ? params->sort : SortingCriteria::Default;
auto desc = params != nullptr ? params->desc : false; auto desc = params != nullptr ? params->desc : false;
...@@ -159,7 +159,7 @@ Query<IShowEpisode> Show::episodes( const QueryParameters* params ) const ...@@ -159,7 +159,7 @@ Query<IShowEpisode> Show::episodes( const QueryParameters* params ) const
break; break;
} }
return make_query<ShowEpisode, IShowEpisode>( m_ml, "*", req, m_id ); return make_query<Media, IMedia>( m_ml, "*", req, m_id );
} }
uint32_t Show::nbSeasons() const uint32_t Show::nbSeasons() const
......
...@@ -63,7 +63,7 @@ class Show : public IShow, public DatabaseHelpers<Show, policy::ShowTable> ...@@ -63,7 +63,7 @@ class Show : public IShow, public DatabaseHelpers<Show, policy::ShowTable>
virtual const std::string& tvdbId() const override; virtual const std::string& tvdbId() const override;
bool setTvdbId( const std::string& summary ); bool setTvdbId( const std::string& summary );
std::shared_ptr<ShowEpisode> addEpisode( Media& media, unsigned int episodeNumber ); std::shared_ptr<ShowEpisode> addEpisode( Media& media, unsigned int episodeNumber );
virtual Query<IShowEpisode> episodes( const QueryParameters* params ) const override; virtual Query<IMedia> episodes( const QueryParameters* params ) const override;
virtual uint32_t nbSeasons() const override; virtual uint32_t nbSeasons() const override;
virtual uint32_t nbEpisodes() const override; virtual uint32_t nbEpisodes() const override;
......
...@@ -127,7 +127,7 @@ TEST_F( Shows, AddEpisode ) ...@@ -127,7 +127,7 @@ TEST_F( Shows, AddEpisode )
auto episodes = show->episodes( nullptr )->all(); auto episodes = show->episodes( nullptr )->all();
ASSERT_EQ( episodes.size(), 1u ); ASSERT_EQ( episodes.size(), 1u );
ASSERT_EQ( episodes[0], e ); ASSERT_EQ( episodes[0]->showEpisode(), e );
} }
TEST_F( Shows, FetchShowFromEpisode ) TEST_F( Shows, FetchShowFromEpisode )
...@@ -164,7 +164,7 @@ TEST_F( Shows, SetEpisodeSeasonNumber ) ...@@ -164,7 +164,7 @@ TEST_F( Shows, SetEpisodeSeasonNumber )
show = std::static_pointer_cast<Show>( ml->show( show->id() ) ); show = std::static_pointer_cast<Show>( ml->show( show->id() ) );
auto episodes = show->episodes( nullptr )->all(); auto episodes = show->episodes( nullptr )->all();
ASSERT_EQ( episodes[0]->seasonNumber(), e->seasonNumber() ); ASSERT_EQ( episodes[0]->showEpisode()->seasonNumber(), e->seasonNumber() );
} }
TEST_F( Shows, SetEpisodeSummary ) TEST_F( Shows, SetEpisodeSummary )
...@@ -180,7 +180,7 @@ TEST_F( Shows, SetEpisodeSummary ) ...@@ -180,7 +180,7 @@ TEST_F( Shows, SetEpisodeSummary )
show = std::static_pointer_cast<Show>( ml->show( show->id() ) ); show = std::static_pointer_cast<Show>( ml->show( show->id() ) );
auto episodes = show->episodes( nullptr )->all(); auto episodes = show->episodes( nullptr )->all();
ASSERT_EQ( episodes[0]->shortSummary(), e->shortSummary() ); ASSERT_EQ( episodes[0]->showEpisode()->shortSummary(), e->shortSummary() );
} }
TEST_F( Shows, SetEpisodeTvdbId ) TEST_F( Shows, SetEpisodeTvdbId )
...@@ -196,7 +196,7 @@ TEST_F( Shows, SetEpisodeTvdbId ) ...@@ -196,7 +196,7 @@ TEST_F( Shows, SetEpisodeTvdbId )
show = std::static_pointer_cast<Show>( ml->show( show->id() ) ); show = std::static_pointer_cast<Show>( ml->show( show->id() ) );
auto episodes = show->episodes( nullptr )->all(); auto episodes = show->episodes( nullptr )->all();
ASSERT_EQ( episodes[0]->tvdbId(), e->tvdbId() ); ASSERT_EQ( episodes[0]->showEpisode()->tvdbId(), e->tvdbId() );
} }
TEST_F( Shows, ListAll ) TEST_F( Shows, ListAll )
......
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