Merge branch 'showTorrentsStats' into 'master'

Fix shows and episodes torrent stats

See merge request !89
This commit is contained in:
Grégoire Delattre 2017-12-18 12:22:09 +00:00
commit 6a36b6a417
2 changed files with 10 additions and 2 deletions

View File

@ -13,8 +13,9 @@ const (
moviesTorrentsCountByIDQuery = `SELECT COUNT(*) FROM (SELECT DISTINCT(imdb_id) FROM movie_torrents) as TMP;` moviesTorrentsCountByIDQuery = `SELECT COUNT(*) FROM (SELECT DISTINCT(imdb_id) FROM movie_torrents) as TMP;`
moviesTorrentsCountQuery = `SELECT COUNT(*) FROM movie_torrents;` moviesTorrentsCountQuery = `SELECT COUNT(*) FROM movie_torrents;`
showsCountQuery = `SELECT COUNT(*) FROM shows;` showsCountQuery = `SELECT COUNT(*) FROM shows;`
showsTorrentsCountByIDQuery = `SELECT COUNT(*) FROM (SELECT DISTINCT(imdb_id) FROM episode_torrents) as TMP;`
episodesCountQuery = `SELECT COUNT(*) FROM episodes;` episodesCountQuery = `SELECT COUNT(*) FROM episodes;`
episodesTorrentsCountByIDQuery = `SELECT COUNT(*) FROM (SELECT DISTINCT(imdb_id) FROM episode_torrents) as TMP;` episodesTorrentsCountByIDQuery = `SELECT COUNT(*) FROM (SELECT DISTINCT(imdb_id, season, episode) FROM episode_torrents) as TMP;`
episodesTorrentsCountQuery = `SELECT COUNT(*) FROM episode_torrents;` episodesTorrentsCountQuery = `SELECT COUNT(*) FROM episode_torrents;`
) )
@ -41,6 +42,7 @@ func GetStatsHandler(env *web.Env, w http.ResponseWriter, r *http.Request) error
MoviesTorrentsCount int `json:"movies_torrents_count"` MoviesTorrentsCount int `json:"movies_torrents_count"`
MoviesTorrentsCountByID int `json:"movies_torrents_count_by_id"` MoviesTorrentsCountByID int `json:"movies_torrents_count_by_id"`
ShowsCount int `json:"shows_count"` ShowsCount int `json:"shows_count"`
ShowsTorrentsCountByID int `json:"shows_torrents_count_by_id"`
EpisodesCount int `json:"episodes_count"` EpisodesCount int `json:"episodes_count"`
EpisodesTorrentsCount int `json:"episodes_torrents_count"` EpisodesTorrentsCount int `json:"episodes_torrents_count"`
EpisodesTorrentsCountByID int `json:"episodes_torrents_count_by_id"` EpisodesTorrentsCountByID int `json:"episodes_torrents_count_by_id"`
@ -54,6 +56,7 @@ func GetStatsHandler(env *web.Env, w http.ResponseWriter, r *http.Request) error
{moviesTorrentsCountQuery, &stats.MoviesTorrentsCount}, {moviesTorrentsCountQuery, &stats.MoviesTorrentsCount},
{moviesTorrentsCountByIDQuery, &stats.MoviesTorrentsCountByID}, {moviesTorrentsCountByIDQuery, &stats.MoviesTorrentsCountByID},
{showsCountQuery, &stats.ShowsCount}, {showsCountQuery, &stats.ShowsCount},
{showsTorrentsCountByIDQuery, &stats.ShowsTorrentsCountByID},
{episodesCountQuery, &stats.EpisodesCount}, {episodesCountQuery, &stats.EpisodesCount},
{episodesTorrentsCountQuery, &stats.EpisodesTorrentsCount}, {episodesTorrentsCountQuery, &stats.EpisodesTorrentsCount},
{episodesTorrentsCountByIDQuery, &stats.EpisodesTorrentsCountByID}, {episodesTorrentsCountByIDQuery, &stats.EpisodesTorrentsCountByID},

View File

@ -10,7 +10,12 @@ export default function Stats(props) {
torrentCount={props.stats.get("movies_torrents_count")} torrentCount={props.stats.get("movies_torrents_count")}
torrentCountById={props.stats.get("movies_torrents_count_by_id")} torrentCountById={props.stats.get("movies_torrents_count_by_id")}
/> />
<Stat name="Shows" count={props.stats.get("shows_count")} /> <Stat
name="Shows"
count={props.stats.get("shows_count")}
torrentCount={props.stats.get("episodes_torrents_count")}
torrentCountById={props.stats.get("shows_torrents_count_by_id")}
/>
<Stat <Stat
name="Episodes" name="Episodes"
count={props.stats.get("episodes_count")} count={props.stats.get("episodes_count")}