mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Add additional stats to the Stats page (#3812)
* Add o_counter, play_duration, play_count, unique_play_count stats
This commit is contained in:
@@ -705,6 +705,18 @@ func (qb *SceneStore) OCountByPerformerID(ctx context.Context, performerID int)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *SceneStore) OCount(ctx context.Context) (int, error) {
|
||||
table := qb.table()
|
||||
|
||||
q := dialect.Select(goqu.COALESCE(goqu.SUM("o_counter"), 0)).From(table)
|
||||
var ret int
|
||||
if err := querySimple(ctx, q, &ret); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *SceneStore) FindByMovieID(ctx context.Context, movieID int) ([]*models.Scene, error) {
|
||||
sq := dialect.From(scenesMoviesJoinTable).Select(scenesMoviesJoinTable.Col(sceneIDColumn)).Where(
|
||||
scenesMoviesJoinTable.Col(movieIDColumn).Eq(movieID),
|
||||
@@ -730,6 +742,24 @@ func (qb *SceneStore) Count(ctx context.Context) (int, error) {
|
||||
return count(ctx, q)
|
||||
}
|
||||
|
||||
func (qb *SceneStore) PlayCount(ctx context.Context) (int, error) {
|
||||
q := dialect.Select(goqu.COALESCE(goqu.SUM("play_count"), 0)).From(qb.table())
|
||||
|
||||
var ret int
|
||||
if err := querySimple(ctx, q, &ret); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *SceneStore) UniqueScenePlayCount(ctx context.Context) (int, error) {
|
||||
table := qb.table()
|
||||
q := dialect.Select(goqu.COUNT("*")).From(table).Where(table.Col("play_count").Gt(0))
|
||||
|
||||
return count(ctx, q)
|
||||
}
|
||||
|
||||
func (qb *SceneStore) Size(ctx context.Context) (float64, error) {
|
||||
table := qb.table()
|
||||
fileTable := fileTableMgr.table
|
||||
@@ -771,6 +801,19 @@ func (qb *SceneStore) Duration(ctx context.Context) (float64, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *SceneStore) PlayDuration(ctx context.Context) (float64, error) {
|
||||
table := qb.table()
|
||||
|
||||
q := dialect.Select(goqu.COALESCE(goqu.SUM("play_duration"), 0)).From(table)
|
||||
|
||||
var ret float64
|
||||
if err := querySimple(ctx, q, &ret); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *SceneStore) CountByStudioID(ctx context.Context, studioID int) (int, error) {
|
||||
table := qb.table()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user