mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +03:00
Include image total O-Count on stats page (#4386)
This commit is contained in:
@@ -168,27 +168,90 @@ func (r *queryResolver) Stats(ctx context.Context) (*StatsResultType, error) {
|
|||||||
var ret StatsResultType
|
var ret StatsResultType
|
||||||
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
|
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
|
||||||
repo := r.repository
|
repo := r.repository
|
||||||
scenesQB := repo.Scene
|
sceneQB := repo.Scene
|
||||||
imageQB := repo.Image
|
imageQB := repo.Image
|
||||||
galleryQB := repo.Gallery
|
galleryQB := repo.Gallery
|
||||||
studiosQB := repo.Studio
|
studioQB := repo.Studio
|
||||||
performersQB := repo.Performer
|
performerQB := repo.Performer
|
||||||
moviesQB := repo.Movie
|
movieQB := repo.Movie
|
||||||
tagsQB := repo.Tag
|
tagQB := repo.Tag
|
||||||
scenesCount, _ := scenesQB.Count(ctx)
|
|
||||||
scenesSize, _ := scenesQB.Size(ctx)
|
// embrace the error
|
||||||
scenesDuration, _ := scenesQB.Duration(ctx)
|
|
||||||
imageCount, _ := imageQB.Count(ctx)
|
scenesCount, err := sceneQB.Count(ctx)
|
||||||
imageSize, _ := imageQB.Size(ctx)
|
if err != nil {
|
||||||
galleryCount, _ := galleryQB.Count(ctx)
|
return err
|
||||||
performersCount, _ := performersQB.Count(ctx)
|
}
|
||||||
studiosCount, _ := studiosQB.Count(ctx)
|
|
||||||
moviesCount, _ := moviesQB.Count(ctx)
|
scenesSize, err := sceneQB.Size(ctx)
|
||||||
tagsCount, _ := tagsQB.Count(ctx)
|
if err != nil {
|
||||||
totalOCount, _ := scenesQB.OCount(ctx)
|
return err
|
||||||
totalPlayDuration, _ := scenesQB.PlayDuration(ctx)
|
}
|
||||||
totalPlayCount, _ := scenesQB.PlayCount(ctx)
|
|
||||||
uniqueScenePlayCount, _ := scenesQB.UniqueScenePlayCount(ctx)
|
scenesDuration, err := sceneQB.Duration(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
imageCount, err := imageQB.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
imageSize, err := imageQB.Size(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
galleryCount, err := galleryQB.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
performersCount, err := performerQB.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
studiosCount, err := studioQB.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
moviesCount, err := movieQB.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tagsCount, err := tagQB.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
scenesTotalOCount, err := sceneQB.OCount(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
imagesTotalOCount, err := imageQB.OCount(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
totalOCount := scenesTotalOCount + imagesTotalOCount
|
||||||
|
|
||||||
|
totalPlayDuration, err := sceneQB.PlayDuration(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
totalPlayCount, err := sceneQB.PlayCount(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
uniqueScenePlayCount, err := sceneQB.UniqueScenePlayCount(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
ret = StatsResultType{
|
ret = StatsResultType{
|
||||||
SceneCount: scenesCount,
|
SceneCount: scenesCount,
|
||||||
|
|||||||
@@ -506,6 +506,27 @@ func (_m *ImageReaderWriter) IncrementOCounter(ctx context.Context, id int) (int
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OCount provides a mock function with given fields: ctx
|
||||||
|
func (_m *ImageReaderWriter) OCount(ctx context.Context) (int, error) {
|
||||||
|
ret := _m.Called(ctx)
|
||||||
|
|
||||||
|
var r0 int
|
||||||
|
if rf, ok := ret.Get(0).(func(context.Context) int); ok {
|
||||||
|
r0 = rf(ctx)
|
||||||
|
} else {
|
||||||
|
r0 = ret.Get(0).(int)
|
||||||
|
}
|
||||||
|
|
||||||
|
var r1 error
|
||||||
|
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||||
|
r1 = rf(ctx)
|
||||||
|
} else {
|
||||||
|
r1 = ret.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
|
}
|
||||||
|
|
||||||
// OCountByPerformerID provides a mock function with given fields: ctx, performerID
|
// OCountByPerformerID provides a mock function with given fields: ctx, performerID
|
||||||
func (_m *ImageReaderWriter) OCountByPerformerID(ctx context.Context, performerID int) (int, error) {
|
func (_m *ImageReaderWriter) OCountByPerformerID(ctx context.Context, performerID int) (int, error) {
|
||||||
ret := _m.Called(ctx, performerID)
|
ret := _m.Called(ctx, performerID)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ type ImageCounter interface {
|
|||||||
Count(ctx context.Context) (int, error)
|
Count(ctx context.Context) (int, error)
|
||||||
CountByFileID(ctx context.Context, fileID FileID) (int, error)
|
CountByFileID(ctx context.Context, fileID FileID) (int, error)
|
||||||
CountByGalleryID(ctx context.Context, galleryID int) (int, error)
|
CountByGalleryID(ctx context.Context, galleryID int) (int, error)
|
||||||
|
OCount(ctx context.Context) (int, error)
|
||||||
OCountByPerformerID(ctx context.Context, performerID int) (int, error)
|
OCountByPerformerID(ctx context.Context, performerID int) (int, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -551,6 +551,18 @@ func (qb *ImageStore) OCountByPerformerID(ctx context.Context, performerID int)
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (qb *ImageStore) 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 *ImageStore) FindByFolderID(ctx context.Context, folderID models.FolderID) ([]*models.Image, error) {
|
func (qb *ImageStore) FindByFolderID(ctx context.Context, folderID models.FolderID) ([]*models.Image, error) {
|
||||||
table := qb.table()
|
table := qb.table()
|
||||||
fileTable := goqu.T(fileTable)
|
fileTable := goqu.T(fileTable)
|
||||||
|
|||||||
Reference in New Issue
Block a user