diff --git a/modules/backend/handlers/titles.go b/modules/backend/handlers/titles.go index 45d4c9b..9f076d5 100644 --- a/modules/backend/handlers/titles.go +++ b/modules/backend/handlers/titles.go @@ -117,6 +117,9 @@ func (s Server) GetStudio(ctx context.Context, id int64) (*oapi.Studio, error) { oapi_studio.Name = sqlc_studio.StudioName oapi_studio.Description = sqlc_studio.StudioDesc + if sqlc_studio.IllustID == nil { + return &oapi_studio, nil + } oapi_illust, err := s.GetImage(ctx, *sqlc_studio.IllustID) if err != nil { return &oapi_studio, fmt.Errorf("GetImage: %v", err) @@ -152,12 +155,14 @@ func (s Server) mapTitle(ctx context.Context, title sqlc.Title) (oapi.Title, err oapi_title.Tags = oapi_tag_names } - oapi_image, err := s.GetImage(ctx, *title.PosterID) - if err != nil { - return oapi_title, fmt.Errorf("GetImage: %v", err) - } - if oapi_image != nil { - oapi_title.Poster = oapi_image + if title.PosterID != nil { + oapi_image, err := s.GetImage(ctx, *title.PosterID) + if err != nil { + return oapi_title, fmt.Errorf("GetImage: %v", err) + } + if oapi_image != nil { + oapi_title.Poster = oapi_image + } } oapi_studio, err := s.GetStudio(ctx, title.StudioID) diff --git a/sql/migrations/000001_init.up.sql b/sql/migrations/000001_init.up.sql index 81f2801..8bd40d1 100644 --- a/sql/migrations/000001_init.up.sql +++ b/sql/migrations/000001_init.up.sql @@ -60,6 +60,7 @@ CREATE TABLE studios ( ); CREATE TABLE titles ( + // TODO: anime type (film, season etc) id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, -- example {"ru": ["Атака титанов", "Атака Титанов"],"en": ["Attack on Titan", "AoT"],"ja": ["進撃の巨人", "しんげきのきょじん"]} title_names jsonb NOT NULL, @@ -88,6 +89,7 @@ CREATE TABLE usertitles ( rate int CHECK (rate > 0 AND rate <= 10), review_text text, review_date timestamptz + // TODO: series status ); CREATE TABLE title_tags (