Added most played artists feature
This commit is contained in:
@@ -3,6 +3,10 @@
|
|||||||
<!--FORMS message blocks-->
|
<!--FORMS message blocks-->
|
||||||
|
|
||||||
<message id="Lms.Explore.Artists.template">
|
<message id="Lms.Explore.Artists.template">
|
||||||
|
<div class="page-header">
|
||||||
|
<h2>${tr:Lms.Explore.most-played-artists}</h2>
|
||||||
|
</div>
|
||||||
|
${most-played-artists}
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2>${tr:Lms.Explore.artists}</h2>
|
<h2>${tr:Lms.Explore.artists}</h2>
|
||||||
</div>
|
</div>
|
||||||
@@ -16,6 +20,10 @@
|
|||||||
${show-more}
|
${show-more}
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<message id="Lms.Explore.Artists.template.most-played-entry">
|
||||||
|
${name}
|
||||||
|
</message>
|
||||||
|
|
||||||
<message id="Lms.Explore.Artists.template.entry">
|
<message id="Lms.Explore.Artists.template.entry">
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<span class="badge">${nb-release}</span>
|
<span class="badge">${nb-release}</span>
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
<!--Explore-->
|
<!--Explore-->
|
||||||
<message id="Lms.Explore.add-filter">Add filter</message>
|
<message id="Lms.Explore.add-filter">Add filter</message>
|
||||||
<message id="Lms.Explore.artists">Artists</message>
|
<message id="Lms.Explore.artists">Artists</message>
|
||||||
|
<message id="Lms.Explore.most-played-artists">Most played artists</message>
|
||||||
<message id="Lms.Explore.releases">Albums</message>
|
<message id="Lms.Explore.releases">Albums</message>
|
||||||
<message id="Lms.Explore.search-placeholder">Search...</message>
|
<message id="Lms.Explore.search-placeholder">Search...</message>
|
||||||
<message id="Lms.Explore.show-more">Show more</message>
|
<message id="Lms.Explore.show-more">Show more</message>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ lms_SOURCES = \
|
|||||||
$(srcdir)/database/ScanSettings.cpp \
|
$(srcdir)/database/ScanSettings.cpp \
|
||||||
$(srcdir)/database/SqlQuery.cpp \
|
$(srcdir)/database/SqlQuery.cpp \
|
||||||
$(srcdir)/database/Track.cpp \
|
$(srcdir)/database/Track.cpp \
|
||||||
|
$(srcdir)/database/TrackStats.cpp \
|
||||||
$(srcdir)/database/User.cpp \
|
$(srcdir)/database/User.cpp \
|
||||||
$(srcdir)/image/Image.cpp \
|
$(srcdir)/image/Image.cpp \
|
||||||
$(srcdir)/metadata/AvFormat.cpp \
|
$(srcdir)/metadata/AvFormat.cpp \
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include "Release.hpp"
|
#include "Release.hpp"
|
||||||
#include "ScanSettings.hpp"
|
#include "ScanSettings.hpp"
|
||||||
#include "Track.hpp"
|
#include "Track.hpp"
|
||||||
|
#include "TrackStats.hpp"
|
||||||
|
|
||||||
namespace Database {
|
namespace Database {
|
||||||
|
|
||||||
@@ -106,6 +107,7 @@ Handler::Handler(Wt::Dbo::SqlConnectionPool& connectionPool)
|
|||||||
_session.mapClass<Release>("release");
|
_session.mapClass<Release>("release");
|
||||||
_session.mapClass<Setting>("setting");
|
_session.mapClass<Setting>("setting");
|
||||||
_session.mapClass<Track>("track");
|
_session.mapClass<Track>("track");
|
||||||
|
_session.mapClass<TrackStats>("track_stats");
|
||||||
|
|
||||||
_session.mapClass<ScanSettings>("scan_settings");
|
_session.mapClass<ScanSettings>("scan_settings");
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,11 @@
|
|||||||
namespace Database {
|
namespace Database {
|
||||||
|
|
||||||
class Artist;
|
class Artist;
|
||||||
class Release;
|
|
||||||
class PlaylistEntry;
|
|
||||||
class Cluster;
|
class Cluster;
|
||||||
class ClusterType;
|
class ClusterType;
|
||||||
|
class PlaylistEntry;
|
||||||
|
class Release;
|
||||||
|
class TrackStats;
|
||||||
|
|
||||||
class Track : public Wt::Dbo::Dbo<Track>
|
class Track : public Wt::Dbo::Dbo<Track>
|
||||||
{
|
{
|
||||||
@@ -143,6 +144,7 @@ class Track : public Wt::Dbo::Dbo<Track>
|
|||||||
Wt::Dbo::belongsTo(a, _artist, "artist", Wt::Dbo::OnDeleteCascade);
|
Wt::Dbo::belongsTo(a, _artist, "artist", Wt::Dbo::OnDeleteCascade);
|
||||||
Wt::Dbo::hasMany(a, _clusters, Wt::Dbo::ManyToMany, "track_cluster", "", Wt::Dbo::OnDeleteCascade);
|
Wt::Dbo::hasMany(a, _clusters, Wt::Dbo::ManyToMany, "track_cluster", "", Wt::Dbo::OnDeleteCascade);
|
||||||
Wt::Dbo::hasMany(a, _playlistEntries, Wt::Dbo::ManyToOne, "track");
|
Wt::Dbo::hasMany(a, _playlistEntries, Wt::Dbo::ManyToOne, "track");
|
||||||
|
Wt::Dbo::hasMany(a, _stats, Wt::Dbo::ManyToOne, "track");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -170,8 +172,9 @@ class Track : public Wt::Dbo::Dbo<Track>
|
|||||||
|
|
||||||
Wt::Dbo::ptr<Artist> _artist;
|
Wt::Dbo::ptr<Artist> _artist;
|
||||||
Wt::Dbo::ptr<Release> _release;
|
Wt::Dbo::ptr<Release> _release;
|
||||||
Wt::Dbo::collection< Wt::Dbo::ptr<Cluster> > _clusters;
|
Wt::Dbo::collection<Wt::Dbo::ptr<Cluster>> _clusters;
|
||||||
Wt::Dbo::collection< Wt::Dbo::ptr<PlaylistEntry> > _playlistEntries;
|
Wt::Dbo::collection<Wt::Dbo::ptr<PlaylistEntry>> _playlistEntries;
|
||||||
|
Wt::Dbo::collection<Wt::Dbo::ptr<TrackStats>> _stats;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
|
|
||||||
#include "database/Playlist.hpp"
|
#include "database/Playlist.hpp"
|
||||||
|
#include "database/TrackStats.hpp"
|
||||||
|
|
||||||
#include "LmsApplication.hpp"
|
#include "LmsApplication.hpp"
|
||||||
|
|
||||||
@@ -116,7 +117,12 @@ PlayQueue::play(std::size_t pos)
|
|||||||
addRadioTrack();
|
addRadioTrack();
|
||||||
|
|
||||||
_trackPos = pos;
|
_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);
|
updateCurrentTrack(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "database/Artist.hpp"
|
#include "database/Artist.hpp"
|
||||||
#include "database/Setting.hpp"
|
#include "database/Setting.hpp"
|
||||||
|
#include "database/TrackStats.hpp"
|
||||||
|
|
||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
#include "utils/Utils.hpp"
|
#include "utils/Utils.hpp"
|
||||||
@@ -47,6 +48,7 @@ Artists::Artists(Filters* filters)
|
|||||||
_search->textInput().connect(this, &Artists::refresh);
|
_search->textInput().connect(this, &Artists::refresh);
|
||||||
|
|
||||||
_artistsContainer = bindNew<Wt::WContainerWidget>("artists");
|
_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 = bindNew<Wt::WTemplate>("show-more", Wt::WString::tr("Lms.Explore.template.show-more"));
|
||||||
_showMore->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
_showMore->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||||
@@ -57,10 +59,27 @@ Artists::Artists(Filters* filters)
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
refreshMostPlayed();
|
||||||
|
|
||||||
filters->updated().connect(this, &Artists::refresh);
|
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
|
void
|
||||||
Artists::refresh()
|
Artists::refresh()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class Artists : public Wt::WTemplate
|
|||||||
Wt::Signal<Database::IdType> artistPlay;
|
Wt::Signal<Database::IdType> artistPlay;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void refreshMostPlayed();
|
||||||
void refresh();
|
void refresh();
|
||||||
void addSome();
|
void addSome();
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ class Artists : public Wt::WTemplate
|
|||||||
Wt::WTemplate* _showMore;
|
Wt::WTemplate* _showMore;
|
||||||
Wt::WLineEdit* _search;
|
Wt::WLineEdit* _search;
|
||||||
Wt::WContainerWidget* _artistsContainer;
|
Wt::WContainerWidget* _artistsContainer;
|
||||||
|
Wt::WContainerWidget* _mostPlayedArtistsContainer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|||||||
Reference in New Issue
Block a user