Added most played artists feature
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "utils/Logger.hpp"
|
||||
|
||||
#include "database/Playlist.hpp"
|
||||
#include "database/TrackStats.hpp"
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
@@ -116,7 +117,12 @@ PlayQueue::play(std::size_t pos)
|
||||
addRadioTrack();
|
||||
|
||||
_trackPos = pos;
|
||||
trackId = playlist->getEntry(*_trackPos)->getTrack().id();
|
||||
auto track = playlist->getEntry(*_trackPos)->getTrack();
|
||||
|
||||
trackId = track.id();
|
||||
|
||||
Database::TrackStats::get(LmsApp->getDboSession(), track, LmsApp->getCurrentUser()).modify()->incPlayCount();
|
||||
|
||||
updateCurrentTrack(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "database/Artist.hpp"
|
||||
#include "database/Setting.hpp"
|
||||
#include "database/TrackStats.hpp"
|
||||
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
@@ -47,6 +48,7 @@ Artists::Artists(Filters* filters)
|
||||
_search->textInput().connect(this, &Artists::refresh);
|
||||
|
||||
_artistsContainer = bindNew<Wt::WContainerWidget>("artists");
|
||||
_mostPlayedArtistsContainer = bindNew<Wt::WContainerWidget>("most-played-artists");
|
||||
|
||||
_showMore = bindNew<Wt::WTemplate>("show-more", Wt::WString::tr("Lms.Explore.template.show-more"));
|
||||
_showMore->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
@@ -57,10 +59,27 @@ Artists::Artists(Filters* filters)
|
||||
}));
|
||||
|
||||
refresh();
|
||||
refreshMostPlayed();
|
||||
|
||||
filters->updated().connect(this, &Artists::refresh);
|
||||
}
|
||||
|
||||
void
|
||||
Artists::refreshMostPlayed()
|
||||
{
|
||||
_mostPlayedArtistsContainer->clear();
|
||||
|
||||
Wt::Dbo::Transaction transaction(LmsApp->getDboSession());
|
||||
auto artists = TrackStats::getMostPlayedArtists(LmsApp->getDboSession(), LmsApp->getCurrentUser(), 5);
|
||||
|
||||
for (auto artist : artists)
|
||||
{
|
||||
Wt::WTemplate* entry = _mostPlayedArtistsContainer->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Artists.template.most-played-entry"));
|
||||
|
||||
entry->bindWidget("name", LmsApplication::createArtistAnchor(artist));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Artists::refresh()
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ class Artists : public Wt::WTemplate
|
||||
Wt::Signal<Database::IdType> artistPlay;
|
||||
|
||||
private:
|
||||
void refreshMostPlayed();
|
||||
void refresh();
|
||||
void addSome();
|
||||
|
||||
@@ -46,6 +47,7 @@ class Artists : public Wt::WTemplate
|
||||
Wt::WTemplate* _showMore;
|
||||
Wt::WLineEdit* _search;
|
||||
Wt::WContainerWidget* _artistsContainer;
|
||||
Wt::WContainerWidget* _mostPlayedArtistsContainer;
|
||||
};
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
Reference in New Issue
Block a user