review: review notes for titles.go

This commit is contained in:
nihonium 2025-11-17 02:41:45 +03:00
parent b81cc86beb
commit f888ac9b70
Signed by: nihonium
GPG key ID: 0251623741027CFC

View file

@ -11,6 +11,7 @@ import (
) )
func Word2Sqlc(s *string) *string { func Word2Sqlc(s *string) *string {
// TODO: merge two ifs
if s == nil { if s == nil {
return nil return nil
} }
@ -69,6 +70,7 @@ func (s Server) GetTagsByTitleId(ctx context.Context, id int64) (oapi.Tags, erro
return nil, fmt.Errorf("query GetTitleTags: %v", err) return nil, fmt.Errorf("query GetTitleTags: %v", err)
} }
// TODO: check if underlying slice initialized as nil
var oapi_tag_names oapi.Tags var oapi_tag_names oapi.Tags
for _, title_tag := range sqlc_title_tags { for _, title_tag := range sqlc_title_tags {
var oapi_tag_name map[string]string var oapi_tag_name map[string]string
@ -91,6 +93,7 @@ func (s Server) GetImage(ctx context.Context, id int64) (oapi.Image, error) {
return oapi_image, fmt.Errorf("query GetImageByID: %v", err) return oapi_image, fmt.Errorf("query GetImageByID: %v", err)
} }
// TODO: clearer comment
//can cast and dont use brain cause all this fiels required //can cast and dont use brain cause all this fiels required
oapi_image.Id = &sqlc_image.ID oapi_image.Id = &sqlc_image.ID
oapi_image.ImagePath = &sqlc_image.ImagePath oapi_image.ImagePath = &sqlc_image.ImagePath
@ -101,7 +104,7 @@ func (s Server) GetImage(ctx context.Context, id int64) (oapi.Image, error) {
} }
func (s Server) GetStudio(ctx context.Context, id int64) (oapi.Studio, error) { func (s Server) GetStudio(ctx context.Context, id int64) (oapi.Studio, error) {
// TODO: check all possibly nil fields
var oapi_studio oapi.Studio var oapi_studio oapi.Studio
sqlc_studio, err := s.db.GetStudioByID(ctx, id) sqlc_studio, err := s.db.GetStudioByID(ctx, id)
@ -123,6 +126,7 @@ func (s Server) GetStudio(ctx context.Context, id int64) (oapi.Studio, error) {
} }
func (s Server) mapTitle(ctx context.Context, title sqlc.Title) (oapi.Title, error) { func (s Server) mapTitle(ctx context.Context, title sqlc.Title) (oapi.Title, error) {
// TODO: check all possibly nil fields
var oapi_title oapi.Title var oapi_title oapi.Title
var title_names map[string][]string var title_names map[string][]string