mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +03:00
Show O Counter in Studio card (#5982)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -594,6 +594,27 @@ func (_m *ImageReaderWriter) OCountByPerformerID(ctx context.Context, performerI
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// OCountByStudioID provides a mock function with given fields: ctx, studioID
|
||||
func (_m *ImageReaderWriter) OCountByStudioID(ctx context.Context, studioID int) (int, error) {
|
||||
ret := _m.Called(ctx, studioID)
|
||||
|
||||
var r0 int
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int) int); ok {
|
||||
r0 = rf(ctx, studioID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int) error); ok {
|
||||
r1 = rf(ctx, studioID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Query provides a mock function with given fields: ctx, options
|
||||
func (_m *ImageReaderWriter) Query(ctx context.Context, options models.ImageQueryOptions) (*models.ImageQueryResult, error) {
|
||||
ret := _m.Called(ctx, options)
|
||||
|
||||
@@ -1183,6 +1183,27 @@ func (_m *SceneReaderWriter) OCountByPerformerID(ctx context.Context, performerI
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// OCountByStudioID provides a mock function with given fields: ctx, studioID
|
||||
func (_m *SceneReaderWriter) OCountByStudioID(ctx context.Context, studioID int) (int, error) {
|
||||
ret := _m.Called(ctx, studioID)
|
||||
|
||||
var r0 int
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int) int); ok {
|
||||
r0 = rf(ctx, studioID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int) error); ok {
|
||||
r1 = rf(ctx, studioID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// PlayDuration provides a mock function with given fields: ctx
|
||||
func (_m *SceneReaderWriter) PlayDuration(ctx context.Context) (float64, error) {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
@@ -38,6 +38,7 @@ type ImageCounter interface {
|
||||
CountByGalleryID(ctx context.Context, galleryID int) (int, error)
|
||||
OCount(ctx context.Context) (int, error)
|
||||
OCountByPerformerID(ctx context.Context, performerID int) (int, error)
|
||||
OCountByStudioID(ctx context.Context, studioID int) (int, error)
|
||||
}
|
||||
|
||||
// ImageCreator provides methods to create images.
|
||||
|
||||
@@ -45,6 +45,7 @@ type SceneCounter interface {
|
||||
CountMissingOSHash(ctx context.Context) (int, error)
|
||||
OCountByPerformerID(ctx context.Context, performerID int) (int, error)
|
||||
OCountByGroupID(ctx context.Context, groupID int) (int, error)
|
||||
OCountByStudioID(ctx context.Context, studioID int) (int, error)
|
||||
}
|
||||
|
||||
// SceneCreator provides methods to create scenes.
|
||||
|
||||
@@ -682,6 +682,20 @@ func (qb *ImageStore) OCountByPerformerID(ctx context.Context, performerID int)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *ImageStore) OCountByStudioID(ctx context.Context, studioID int) (int, error) {
|
||||
table := qb.table()
|
||||
q := dialect.Select(goqu.COALESCE(goqu.SUM("o_counter"), 0)).From(table).Where(
|
||||
table.Col(studioIDColumn).Eq(studioID),
|
||||
)
|
||||
|
||||
var ret int
|
||||
if err := querySimple(ctx, q, &ret); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *ImageStore) OCount(ctx context.Context) (int, error) {
|
||||
table := qb.table()
|
||||
|
||||
|
||||
@@ -818,6 +818,23 @@ func (qb *SceneStore) OCountByGroupID(ctx context.Context, groupID int) (int, er
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *SceneStore) OCountByStudioID(ctx context.Context, studioID int) (int, error) {
|
||||
table := qb.table()
|
||||
oHistoryTable := goqu.T(scenesODatesTable)
|
||||
|
||||
q := dialect.Select(goqu.COUNT("*")).From(table).InnerJoin(
|
||||
oHistoryTable,
|
||||
goqu.On(table.Col(idColumn).Eq(oHistoryTable.Col(sceneIDColumn))),
|
||||
).Where(table.Col(studioIDColumn).Eq(studioID))
|
||||
|
||||
var ret int
|
||||
if err := querySimple(ctx, q, &ret); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (qb *SceneStore) FindByGroupID(ctx context.Context, groupID int) ([]*models.Scene, error) {
|
||||
sq := dialect.From(scenesGroupsJoinTable).Select(scenesGroupsJoinTable.Col(sceneIDColumn)).Where(
|
||||
scenesGroupsJoinTable.Col(groupIDColumn).Eq(groupID),
|
||||
|
||||
Reference in New Issue
Block a user