Fix shows and episodes torrent stats

We know display the right number of episodes with torrents and the right
number of shows with available torrents
This commit is contained in:
Lucas BEE 2017-12-18 13:36:55 +01:00
parent f05d0024fc
commit 50a3599992
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;`
moviesTorrentsCountQuery = `SELECT COUNT(*) FROM movie_torrents;`
showsCountQuery = `SELECT COUNT(*) FROM shows;`
showsTorrentsCountByIDQuery = `SELECT COUNT(*) FROM (SELECT DISTINCT(imdb_id) FROM episode_torrents) as TMP;`
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;`
)
@ -41,6 +42,7 @@ func GetStatsHandler(env *web.Env, w http.ResponseWriter, r *http.Request) error
MoviesTorrentsCount int `json:"movies_torrents_count"`
MoviesTorrentsCountByID int `json:"movies_torrents_count_by_id"`
ShowsCount int `json:"shows_count"`
ShowsTorrentsCountByID int `json:"shows_torrents_count_by_id"`
EpisodesCount int `json:"episodes_count"`
EpisodesTorrentsCount int `json:"episodes_torrents_count"`
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},
{moviesTorrentsCountByIDQuery, &stats.MoviesTorrentsCountByID},
{showsCountQuery, &stats.ShowsCount},
{showsTorrentsCountByIDQuery, &stats.ShowsTorrentsCountByID},
{episodesCountQuery, &stats.EpisodesCount},
{episodesTorrentsCountQuery, &stats.EpisodesTorrentsCount},
{episodesTorrentsCountByIDQuery, &stats.EpisodesTorrentsCountByID},

View File

@ -10,7 +10,12 @@ export default function Stats(props) {
torrentCount={props.stats.get("movies_torrents_count")}
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
name="Episodes"
count={props.stats.get("episodes_count")}