Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organised flag #988

Merged
merged 13 commits into from
Dec 17, 2020
1 change: 1 addition & 0 deletions graphql/documents/data/gallery-slim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fragment GallerySlimData on Gallery {
url
details
rating
organized
image_count
cover {
...SlimImageData
Expand Down
1 change: 1 addition & 0 deletions graphql/documents/data/gallery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fragment GalleryData on Gallery {
url
details
rating
organized
images {
...SlimImageData
}
Expand Down
1 change: 1 addition & 0 deletions graphql/documents/data/image-slim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ fragment SlimImageData on Image {
checksum
title
rating
organized
o_counter
path

Expand Down
1 change: 1 addition & 0 deletions graphql/documents/data/image.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ fragment ImageData on Image {
checksum
title
rating
organized
o_counter
path

Expand Down
1 change: 1 addition & 0 deletions graphql/documents/data/scene-slim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fragment SlimSceneData on Scene {
date
rating
o_counter
organized
path

file {
Expand Down
1 change: 1 addition & 0 deletions graphql/documents/data/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fragment SceneData on Scene {
date
rating
o_counter
organized
path

file {
Expand Down
1 change: 1 addition & 0 deletions graphql/documents/mutations/gallery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mutation GalleryCreate(
$url: String,
$date: String,
$rating: Int,
$organized: Boolean,
$scene_id: ID,
$studio_id: ID,
$performer_ids: [ID!] = [],
Expand Down
6 changes: 6 additions & 0 deletions graphql/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ input SceneFilterType {
path: StringCriterionInput
"""Filter by rating"""
rating: IntCriterionInput
"""Filter by organized"""
organized: Boolean
"""Filter by o-counter"""
o_counter: IntCriterionInput
"""Filter by resolution"""
Expand Down Expand Up @@ -117,6 +119,8 @@ input GalleryFilterType {
is_zip: Boolean
"""Filter by rating"""
rating: IntCriterionInput
"""Filter by organized"""
organized: Boolean
"""Filter by average image resolution"""
average_resolution: ResolutionEnum
"""Filter to only include scenes with this studio"""
Expand Down Expand Up @@ -145,6 +149,8 @@ input ImageFilterType {
path: StringCriterionInput
"""Filter by rating"""
rating: IntCriterionInput
"""Filter by organized"""
organized: Boolean
"""Filter by o-counter"""
o_counter: IntCriterionInput
"""Filter by resolution"""
Expand Down
4 changes: 4 additions & 0 deletions graphql/schema/types/gallery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Gallery {
date: String
details: String
rating: Int
organized: Boolean!
scene: Scene
studio: Studio
image_count: Int!
Expand All @@ -31,6 +32,7 @@ input GalleryCreateInput {
date: String
details: String
rating: Int
organized: Boolean
scene_id: ID
studio_id: ID
tag_ids: [ID!]
Expand All @@ -45,6 +47,7 @@ input GalleryUpdateInput {
date: String
details: String
rating: Int
organized: Boolean
scene_id: ID
studio_id: ID
tag_ids: [ID!]
Expand All @@ -58,6 +61,7 @@ input BulkGalleryUpdateInput {
date: String
details: String
rating: Int
organized: Boolean
scene_id: ID
studio_id: ID
tag_ids: BulkUpdateIds
Expand Down
3 changes: 3 additions & 0 deletions graphql/schema/types/image.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type Image {
title: String
rating: Int
o_counter: Int
organized: Boolean!
path: String!

file: ImageFileType! # Resolver
Expand Down Expand Up @@ -31,6 +32,7 @@ input ImageUpdateInput {
id: ID!
title: String
rating: Int
organized: Boolean

studio_id: ID
performer_ids: [ID!]
Expand All @@ -43,6 +45,7 @@ input BulkImageUpdateInput {
ids: [ID!]
title: String
rating: Int
organized: Boolean

studio_id: ID
performer_ids: BulkUpdateIds
Expand Down
3 changes: 3 additions & 0 deletions graphql/schema/types/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Scene {
url: String
date: String
rating: Int
organized: Boolean!
o_counter: Int
path: String!

Expand Down Expand Up @@ -60,6 +61,7 @@ input SceneUpdateInput {
url: String
date: String
rating: Int
organized: Boolean
studio_id: ID
gallery_id: ID
performer_ids: [ID!]
Expand Down Expand Up @@ -89,6 +91,7 @@ input BulkSceneUpdateInput {
url: String
date: String
rating: Int
organized: Boolean
studio_id: ID
gallery_id: ID
performer_ids: BulkUpdateIds
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/resolver_mutation_gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func (r *mutationResolver) galleryUpdate(input models.GalleryUpdateInput, transl
updatedGallery.Date = translator.sqliteDate(input.Date, "date")
updatedGallery.Rating = translator.nullInt64(input.Rating, "rating")
updatedGallery.StudioID = translator.nullInt64FromString(input.StudioID, "studio_id")
updatedGallery.Organized = input.Organized

// gallery scene is set from the scene only

Expand Down Expand Up @@ -272,6 +273,7 @@ func (r *mutationResolver) BulkGalleryUpdate(ctx context.Context, input models.B
updatedGallery.Rating = translator.nullInt64(input.Rating, "rating")
updatedGallery.StudioID = translator.nullInt64FromString(input.StudioID, "studio_id")
updatedGallery.SceneID = translator.nullInt64FromString(input.SceneID, "scene_id")
updatedGallery.Organized = input.Organized

ret := []*models.Gallery{}

Expand Down
2 changes: 2 additions & 0 deletions pkg/api/resolver_mutation_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (r *mutationResolver) imageUpdate(input models.ImageUpdateInput, translator
updatedImage.Title = translator.nullString(input.Title, "title")
updatedImage.Rating = translator.nullInt64(input.Rating, "rating")
updatedImage.StudioID = translator.nullInt64FromString(input.StudioID, "studio_id")
updatedImage.Organized = input.Organized

qb := models.NewImageQueryBuilder()
jqb := models.NewJoinsQueryBuilder()
Expand Down Expand Up @@ -142,6 +143,7 @@ func (r *mutationResolver) BulkImageUpdate(ctx context.Context, input models.Bul
updatedImage.Title = translator.nullString(input.Title, "title")
updatedImage.Rating = translator.nullInt64(input.Rating, "rating")
updatedImage.StudioID = translator.nullInt64FromString(input.StudioID, "studio_id")
updatedImage.Organized = input.Organized

ret := []*models.Image{}

Expand Down
2 changes: 2 additions & 0 deletions pkg/api/resolver_mutation_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (r *mutationResolver) sceneUpdate(input models.SceneUpdateInput, translator
updatedScene.Date = translator.sqliteDate(input.Date, "date")
updatedScene.Rating = translator.nullInt64(input.Rating, "rating")
updatedScene.StudioID = translator.nullInt64FromString(input.StudioID, "studio_id")
updatedScene.Organized = input.Organized

if input.CoverImage != nil && *input.CoverImage != "" {
var err error
Expand Down Expand Up @@ -242,6 +243,7 @@ func (r *mutationResolver) BulkSceneUpdate(ctx context.Context, input models.Bul
updatedScene.Date = translator.sqliteDate(input.Date, "date")
updatedScene.Rating = translator.nullInt64(input.Rating, "rating")
updatedScene.StudioID = translator.nullInt64FromString(input.StudioID, "studio_id")
updatedScene.Organized = input.Organized

ret := []*models.Scene{}

Expand Down
2 changes: 1 addition & 1 deletion pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

var DB *sqlx.DB
var dbPath string
var appSchemaVersion uint = 15
var appSchemaVersion uint = 16
var databaseSchemaVersion uint

const sqlite3Driver = "sqlite3ex"
Expand Down
3 changes: 3 additions & 0 deletions pkg/database/migrations/16_organized_flag.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE `scenes` ADD COLUMN `organized` boolean not null default '0';
ALTER TABLE `images` ADD COLUMN `organized` boolean not null default '0';
ALTER TABLE `galleries` ADD COLUMN `organized` boolean not null default '0';
2 changes: 2 additions & 0 deletions pkg/gallery/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func ToBasicJSON(gallery *models.Gallery) (*jsonschema.Gallery, error) {
newGalleryJSON.Rating = int(gallery.Rating.Int64)
}

newGalleryJSON.Organized = gallery.Organized

if gallery.Details.Valid {
newGalleryJSON.Details = gallery.Details.String
}
Expand Down
41 changes: 22 additions & 19 deletions pkg/gallery/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ const (
)

const (
path = "path"
zip = true
url = "url"
checksum = "checksum"
title = "title"
date = "2001-01-01"
rating = 5
details = "details"
path = "path"
zip = true
url = "url"
checksum = "checksum"
title = "title"
date = "2001-01-01"
rating = 5
organized = true
details = "details"
)

const (
Expand All @@ -58,9 +59,10 @@ func createFullGallery(id int) models.Gallery {
String: date,
Valid: true,
},
Details: modelstest.NullString(details),
Rating: modelstest.NullInt64(rating),
URL: modelstest.NullString(url),
Details: modelstest.NullString(details),
Rating: modelstest.NullInt64(rating),
Organized: organized,
URL: modelstest.NullString(url),
CreatedAt: models.SQLiteTimestamp{
Timestamp: createTime,
},
Expand All @@ -84,14 +86,15 @@ func createEmptyGallery(id int) models.Gallery {

func createFullJSONGallery() *jsonschema.Gallery {
return &jsonschema.Gallery{
Title: title,
Path: path,
Zip: zip,
Checksum: checksum,
Date: date,
Details: details,
Rating: rating,
URL: url,
Title: title,
Path: path,
Zip: zip,
Checksum: checksum,
Date: date,
Details: details,
Rating: rating,
Organized: organized,
URL: url,
CreatedAt: models.JSONTime{
Time: createTime,
},
Expand Down
1 change: 1 addition & 0 deletions pkg/gallery/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (i *Importer) galleryJSONToGallery(galleryJSON jsonschema.Gallery) models.G
newGallery.Rating = sql.NullInt64{Int64: int64(galleryJSON.Rating), Valid: true}
}

newGallery.Organized = galleryJSON.Organized
newGallery.CreatedAt = models.SQLiteTimestamp{Timestamp: galleryJSON.CreatedAt.GetTime()}
newGallery.UpdatedAt = models.SQLiteTimestamp{Timestamp: galleryJSON.UpdatedAt.GetTime()}

Expand Down
22 changes: 12 additions & 10 deletions pkg/gallery/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ func TestImporterName(t *testing.T) {
func TestImporterPreImport(t *testing.T) {
i := Importer{
Input: jsonschema.Gallery{
Path: path,
Checksum: checksum,
Title: title,
Date: date,
Details: details,
Rating: rating,
URL: url,
Path: path,
Checksum: checksum,
Title: title,
Date: date,
Details: details,
Rating: rating,
Organized: organized,
URL: url,
CreatedAt: models.JSONTime{
Time: createdAt,
},
Expand All @@ -83,9 +84,10 @@ func TestImporterPreImport(t *testing.T) {
String: date,
Valid: true,
},
Details: modelstest.NullString(details),
Rating: modelstest.NullInt64(rating),
URL: modelstest.NullString(url),
Details: modelstest.NullString(details),
Rating: modelstest.NullInt64(rating),
Organized: organized,
URL: modelstest.NullString(url),
CreatedAt: models.SQLiteTimestamp{
Timestamp: createdAt,
},
Expand Down
1 change: 1 addition & 0 deletions pkg/image/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func ToBasicJSON(image *models.Image) *jsonschema.Image {
newImageJSON.Rating = int(image.Rating.Int64)
}

newImageJSON.Organized = image.Organized
newImageJSON.OCounter = image.OCounter

newImageJSON.File = getImageFileJSON(image)
Expand Down
Loading