mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +03:00
Add Icons to tags if they have parent/child tags (#3931)
* Add Icons to tags if they have parent/child tags * Refactor TagLink --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -58,6 +58,48 @@ func (_m *TagReaderWriter) Count(ctx context.Context) (int, error) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CountByChildTagID provides a mock function with given fields: ctx, childID
|
||||
func (_m *TagReaderWriter) CountByChildTagID(ctx context.Context, childID int) (int, error) {
|
||||
ret := _m.Called(ctx, childID)
|
||||
|
||||
var r0 int
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int) int); ok {
|
||||
r0 = rf(ctx, childID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int) error); ok {
|
||||
r1 = rf(ctx, childID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CountByParentTagID provides a mock function with given fields: ctx, parentID
|
||||
func (_m *TagReaderWriter) CountByParentTagID(ctx context.Context, parentID int) (int, error) {
|
||||
ret := _m.Called(ctx, parentID)
|
||||
|
||||
var r0 int
|
||||
if rf, ok := ret.Get(0).(func(context.Context, int) int); ok {
|
||||
r0 = rf(ctx, parentID)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, int) error); ok {
|
||||
r1 = rf(ctx, parentID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Create provides a mock function with given fields: ctx, newTag
|
||||
func (_m *TagReaderWriter) Create(ctx context.Context, newTag *models.Tag) error {
|
||||
ret := _m.Called(ctx, newTag)
|
||||
|
||||
@@ -42,6 +42,8 @@ type TagAutoTagQueryer interface {
|
||||
// TagCounter provides methods to count tags.
|
||||
type TagCounter interface {
|
||||
Count(ctx context.Context) (int, error)
|
||||
CountByParentTagID(ctx context.Context, parentID int) (int, error)
|
||||
CountByChildTagID(ctx context.Context, childID int) (int, error)
|
||||
}
|
||||
|
||||
// TagCreator provides methods to create tags.
|
||||
|
||||
@@ -396,6 +396,20 @@ func (qb *TagStore) FindByChildTagID(ctx context.Context, parentID int) ([]*mode
|
||||
return qb.queryTags(ctx, query, args)
|
||||
}
|
||||
|
||||
func (qb *TagStore) CountByParentTagID(ctx context.Context, parentID int) (int, error) {
|
||||
q := dialect.Select(goqu.COUNT("*")).From(goqu.T("tags")).
|
||||
InnerJoin(goqu.T("tags_relations"), goqu.On(goqu.I("tags_relations.parent_id").Eq(goqu.I("tags.id")))).
|
||||
Where(goqu.I("tags_relations.child_id").Eq(goqu.V(parentID))) // Pass the parentID here
|
||||
return count(ctx, q)
|
||||
}
|
||||
|
||||
func (qb *TagStore) CountByChildTagID(ctx context.Context, childID int) (int, error) {
|
||||
q := dialect.Select(goqu.COUNT("*")).From(goqu.T("tags")).
|
||||
InnerJoin(goqu.T("tags_relations"), goqu.On(goqu.I("tags_relations.child_id").Eq(goqu.I("tags.id")))).
|
||||
Where(goqu.I("tags_relations.parent_id").Eq(goqu.V(childID))) // Pass the childID here
|
||||
return count(ctx, q)
|
||||
}
|
||||
|
||||
func (qb *TagStore) Count(ctx context.Context) (int, error) {
|
||||
q := dialect.Select(goqu.COUNT("*")).From(qb.table())
|
||||
return count(ctx, q)
|
||||
|
||||
Reference in New Issue
Block a user