Fixed dashboard

This commit is contained in:
Stash Dev 2019-02-11 12:36:10 -08:00
parent 4f80decce4
commit 29a8f201e8
6 changed files with 37 additions and 13 deletions

View File

@ -85,19 +85,23 @@ func (r *queryResolver) ValidGalleriesForScene(ctx context.Context, scene_id *st
}
func (r *queryResolver) Stats(ctx context.Context) (models.StatsResultType, error) {
//scenesCount, _ := runCountQuery(buildCountQuery(selectAll("scenes")), nil)
//galleryCount, _ := runCountQuery(buildCountQuery(selectAll("galleries")), nil)
//performersCount, _ := runCountQuery(buildCountQuery(selectAll("performers")), nil)
//studiosCount, _ := runCountQuery(buildCountQuery(selectAll("studios")), nil)
//tagsCount, _ := runCountQuery(buildCountQuery(selectAll("tags")), nil)
//return StatsResultType{
// SceneCount: scenesCount,
// GalleryCount: galleryCount,
// PerformerCount: performersCount,
// StudioCount: studiosCount,
// TagCount: tagsCount,
//}, nil
return models.StatsResultType{}, nil // TODO
scenesQB := models.NewSceneQueryBuilder()
scenesCount, _ := scenesQB.Count()
galleryQB := models.NewGalleryQueryBuilder()
galleryCount, _ := galleryQB.Count()
performersQB := models.NewPerformerQueryBuilder()
performersCount, _ := performersQB.Count()
studiosQB := models.NewStudioQueryBuilder()
studiosCount, _ := studiosQB.Count()
tagsQB := models.NewTagQueryBuilder()
tagsCount, _ := tagsQB.Count()
return models.StatsResultType{
SceneCount: scenesCount,
GalleryCount: galleryCount,
PerformerCount: performersCount,
StudioCount: studiosCount,
TagCount: tagsCount,
}, nil
}
// Get scene marker tags which show up under the video.

View File

@ -80,6 +80,10 @@ func (qb *galleryQueryBuilder) ValidGalleriesForScenePath(scenePath string) ([]G
return qb.queryGalleries(query, nil, nil)
}
func (qb *galleryQueryBuilder) Count() (int, error) {
return runCountQuery(buildCountQuery("SELECT galleries.id FROM galleries"), nil)
}
func (qb *galleryQueryBuilder) All() ([]Gallery, error) {
return qb.queryGalleries(selectAll("galleries") + qb.getGallerySort(nil), nil, nil)
}

View File

@ -85,6 +85,10 @@ func (qb *performerQueryBuilder) FindByNames(names []string, tx *sqlx.Tx) ([]Per
return qb.queryPerformers(query, args, tx)
}
func (qb *performerQueryBuilder) Count() (int, error) {
return runCountQuery(buildCountQuery("SELECT performers.id FROM performers"), nil)
}
func (qb *performerQueryBuilder) All() ([]Performer, error) {
return qb.queryPerformers(selectAll("performers") + qb.getPerformerSort(nil), nil, nil)
}

View File

@ -109,6 +109,10 @@ func (qb *sceneQueryBuilder) FindByStudioID(studioID int) ([]Scene, error) {
return qb.queryScenes(scenesForStudioQuery, args, nil)
}
func (qb *sceneQueryBuilder) Count() (int, error) {
return runCountQuery(buildCountQuery("SELECT scenes.id FROM scenes"), nil)
}
func (qb *sceneQueryBuilder) CountByStudioID(studioID int) (int, error) {
args := []interface{}{studioID}
return runCountQuery(buildCountQuery(scenesForStudioQuery), args)

View File

@ -68,6 +68,10 @@ func (qb *studioQueryBuilder) FindByName(name string, tx *sqlx.Tx) (*Studio, err
return qb.queryStudio(query, args, tx)
}
func (qb *studioQueryBuilder) Count() (int, error) {
return runCountQuery(buildCountQuery("SELECT studios.id FROM studios"), nil)
}
func (qb *studioQueryBuilder) All() ([]Studio, error) {
return qb.queryStudios(selectAll("studios") + qb.getStudioSort(nil), nil, nil)
}

View File

@ -102,6 +102,10 @@ func (qb *tagQueryBuilder) FindByNames(names []string, tx *sqlx.Tx) ([]Tag, erro
return qb.queryTags(query, args, tx)
}
func (qb *tagQueryBuilder) Count() (int, error) {
return runCountQuery(buildCountQuery("SELECT tags.id FROM tags"), nil)
}
func (qb *tagQueryBuilder) All() ([]Tag, error) {
return qb.queryTags(selectAll("tags") + qb.getTagSort(nil), nil, nil)
}