Compare commits
No commits in common. "843dfb24b946241eb0106f0e7a72c9c776fd7bf6" and "17ebba47c9c8f6629539310988d149231f7ee344" have entirely different histories.
843dfb24b9
...
17ebba47c9
6 changed files with 65 additions and 84 deletions
|
|
@ -173,11 +173,7 @@ paths:
|
||||||
- in: query
|
- in: query
|
||||||
name: watch_status
|
name: watch_status
|
||||||
schema:
|
schema:
|
||||||
type: array
|
$ref: '#/components/schemas/UserTitleStatus'
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/UserTitleStatus'
|
|
||||||
style: form
|
|
||||||
explode: false
|
|
||||||
- in: query
|
- in: query
|
||||||
name: rating
|
name: rating
|
||||||
schema:
|
schema:
|
||||||
|
|
|
||||||
|
|
@ -189,14 +189,14 @@ type GetUsersUserIdTitlesParams struct {
|
||||||
Word *string `form:"word,omitempty" json:"word,omitempty"`
|
Word *string `form:"word,omitempty" json:"word,omitempty"`
|
||||||
|
|
||||||
// Status List of title statuses to filter
|
// Status List of title statuses to filter
|
||||||
Status *[]TitleStatus `form:"status,omitempty" json:"status,omitempty"`
|
Status *[]TitleStatus `form:"status,omitempty" json:"status,omitempty"`
|
||||||
WatchStatus *[]UserTitleStatus `form:"watch_status,omitempty" json:"watch_status,omitempty"`
|
WatchStatus *UserTitleStatus `form:"watch_status,omitempty" json:"watch_status,omitempty"`
|
||||||
Rating *float64 `form:"rating,omitempty" json:"rating,omitempty"`
|
Rating *float64 `form:"rating,omitempty" json:"rating,omitempty"`
|
||||||
MyRate *int32 `form:"my_rate,omitempty" json:"my_rate,omitempty"`
|
MyRate *int32 `form:"my_rate,omitempty" json:"my_rate,omitempty"`
|
||||||
ReleaseYear *int32 `form:"release_year,omitempty" json:"release_year,omitempty"`
|
ReleaseYear *int32 `form:"release_year,omitempty" json:"release_year,omitempty"`
|
||||||
ReleaseSeason *ReleaseSeason `form:"release_season,omitempty" json:"release_season,omitempty"`
|
ReleaseSeason *ReleaseSeason `form:"release_season,omitempty" json:"release_season,omitempty"`
|
||||||
Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`
|
Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`
|
||||||
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
Fields *string `form:"fields,omitempty" json:"fields,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getter for additional properties for Title. Returns the specified
|
// Getter for additional properties for Title. Returns the specified
|
||||||
|
|
@ -840,7 +840,7 @@ func (siw *ServerInterfaceWrapper) GetUsersUserIdTitles(c *gin.Context) {
|
||||||
|
|
||||||
// ------------- Optional query parameter "watch_status" -------------
|
// ------------- Optional query parameter "watch_status" -------------
|
||||||
|
|
||||||
err = runtime.BindQueryParameter("form", false, false, "watch_status", c.Request.URL.Query(), ¶ms.WatchStatus)
|
err = runtime.BindQueryParameter("form", true, false, "watch_status", c.Request.URL.Query(), ¶ms.WatchStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter watch_status: %w", err), http.StatusBadRequest)
|
siw.ErrorHandler(c, fmt.Errorf("Invalid format for parameter watch_status: %w", err), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,7 @@ get:
|
||||||
- in: query
|
- in: query
|
||||||
name: watch_status
|
name: watch_status
|
||||||
schema:
|
schema:
|
||||||
type: array
|
$ref: '../schemas/enums/UserTitleStatus.yaml'
|
||||||
items:
|
|
||||||
$ref: '../schemas/enums/UserTitleStatus.yaml'
|
|
||||||
style: form
|
|
||||||
explode: false
|
|
||||||
- in: query
|
- in: query
|
||||||
name: rating
|
name: rating
|
||||||
schema:
|
schema:
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ func (s Server) mapTitle(ctx context.Context, title sqlc.GetTitleByIDRow) (oapi.
|
||||||
return oapi.Title{}, fmt.Errorf("unmarshal TitleNames: %v", err)
|
return oapi.Title{}, fmt.Errorf("unmarshal TitleNames: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(title.EpisodesLen) > 0 {
|
if title.EpisodesLen != nil && len(title.EpisodesLen) > 0 {
|
||||||
episodes_lens := make(map[string]float64, 0)
|
episodes_lens := make(map[string]float64, 0)
|
||||||
err = json.Unmarshal(title.EpisodesLen, &episodes_lens)
|
err = json.Unmarshal(title.EpisodesLen, &episodes_lens)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -99,23 +99,3 @@ func parseInt64(s string) (int32, error) {
|
||||||
i, err := strconv.ParseInt(s, 10, 64)
|
i, err := strconv.ParseInt(s, 10, 64)
|
||||||
return int32(i), err
|
return int32(i), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func TitleStatus2Sqlc(s *[]oapi.TitleStatus) ([]sqlc.TitleStatusT, error) {
|
|
||||||
var sqlc_status []sqlc.TitleStatusT
|
|
||||||
if s == nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
for _, t := range *s {
|
|
||||||
switch t {
|
|
||||||
case oapi.TitleStatusFinished:
|
|
||||||
sqlc_status = append(sqlc_status, sqlc.TitleStatusTFinished)
|
|
||||||
case oapi.TitleStatusOngoing:
|
|
||||||
sqlc_status = append(sqlc_status, sqlc.TitleStatusTOngoing)
|
|
||||||
case oapi.TitleStatusPlanned:
|
|
||||||
sqlc_status = append(sqlc_status, sqlc.TitleStatusTPlanned)
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("unexpected tittle status: %s", t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sqlc_status, nil
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,32 @@ func Word2Sqlc(s *string) *string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SqlcStatus struct {
|
||||||
|
ongoing string
|
||||||
|
finished string
|
||||||
|
planned string
|
||||||
|
}
|
||||||
|
|
||||||
|
// func TitleStatus2Sqlc(s *[]oapi.TitleStatus) (*SqlcStatus, error) {
|
||||||
|
// var sqlc_status SqlcStatus
|
||||||
|
// if s == nil {
|
||||||
|
// return &sqlc_status, nil
|
||||||
|
// }
|
||||||
|
// for _, t := range *s {
|
||||||
|
// switch t {
|
||||||
|
// case oapi.TitleStatusFinished:
|
||||||
|
// sqlc_status.finished = "finished"
|
||||||
|
// case oapi.TitleStatusOngoing:
|
||||||
|
// sqlc_status.ongoing = "ongoing"
|
||||||
|
// case oapi.TitleStatusPlanned:
|
||||||
|
// sqlc_status.planned = "planned"
|
||||||
|
// default:
|
||||||
|
// return nil, fmt.Errorf("unexpected tittle status: %s", t)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return &sqlc_status, nil
|
||||||
|
// }
|
||||||
|
|
||||||
func TitleStatus2oapi(s *sqlc.TitleStatusT) (*oapi.TitleStatus, error) {
|
func TitleStatus2oapi(s *sqlc.TitleStatusT) (*oapi.TitleStatus, error) {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
@ -164,15 +190,17 @@ func (s Server) GetTitles(ctx context.Context, request oapi.GetTitlesRequestObje
|
||||||
return oapi.GetTitles400Response{}, err
|
return oapi.GetTitles400Response{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
title_statuses, err := TitleStatus2Sqlc(request.Params.Status)
|
var statuses_sort []string
|
||||||
if err != nil {
|
if request.Params.Status != nil {
|
||||||
log.Errorf("%v", err)
|
for _, s := range *request.Params.Status {
|
||||||
return oapi.GetTitles400Response{}, err
|
ss := string(s) // s type is alias for string
|
||||||
|
statuses_sort = append(statuses_sort, ss)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
params := sqlc.SearchTitlesParams{
|
params := sqlc.SearchTitlesParams{
|
||||||
Word: word,
|
Word: word,
|
||||||
TitleStatuses: title_statuses,
|
TitleStatuses: statuses_sort,
|
||||||
Rating: request.Params.Rating,
|
Rating: request.Params.Rating,
|
||||||
ReleaseYear: request.Params.ReleaseYear,
|
ReleaseYear: request.Params.ReleaseYear,
|
||||||
ReleaseSeason: season,
|
ReleaseSeason: season,
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,13 @@ func sqlDate2oapi(p_date pgtype.Timestamptz) *time.Time {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SqlcUserStatus struct {
|
||||||
|
dropped string
|
||||||
|
finished string
|
||||||
|
planned string
|
||||||
|
in_progress string
|
||||||
|
}
|
||||||
|
|
||||||
// func UserTitleStatus2Sqlc(s *[]oapi.UserTitleStatus) (*SqlcUserStatus, error) {
|
// func UserTitleStatus2Sqlc(s *[]oapi.UserTitleStatus) (*SqlcUserStatus, error) {
|
||||||
// var sqlc_status SqlcUserStatus
|
// var sqlc_status SqlcUserStatus
|
||||||
// if s == nil {
|
// if s == nil {
|
||||||
|
|
@ -103,28 +110,6 @@ func sql2usertitlestatus(s sqlc.UsertitleStatusT) (oapi.UserTitleStatus, error)
|
||||||
return status, nil
|
return status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserTitleStatus2Sqlc(s *[]oapi.UserTitleStatus) ([]sqlc.UsertitleStatusT, error) {
|
|
||||||
var sqlc_status []sqlc.UsertitleStatusT
|
|
||||||
if s == nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
for _, t := range *s {
|
|
||||||
switch t {
|
|
||||||
case oapi.UserTitleStatusFinished:
|
|
||||||
sqlc_status = append(sqlc_status, sqlc.UsertitleStatusTFinished)
|
|
||||||
case oapi.UserTitleStatusInProgress:
|
|
||||||
sqlc_status = append(sqlc_status, sqlc.UsertitleStatusTInProgress)
|
|
||||||
case oapi.UserTitleStatusDropped:
|
|
||||||
sqlc_status = append(sqlc_status, sqlc.UsertitleStatusTDropped)
|
|
||||||
case oapi.UserTitleStatusPlanned:
|
|
||||||
sqlc_status = append(sqlc_status, sqlc.UsertitleStatusTPlanned)
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("unexpected tittle status: %s", t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sqlc_status, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Server) mapUsertitle(ctx context.Context, t sqlc.SearchUserTitlesRow) (oapi.UserTitle, error) {
|
func (s Server) mapUsertitle(ctx context.Context, t sqlc.SearchUserTitlesRow) (oapi.UserTitle, error) {
|
||||||
|
|
||||||
oapi_usertitle := oapi.UserTitle{
|
oapi_usertitle := oapi.UserTitle{
|
||||||
|
|
@ -186,29 +171,25 @@ func (s Server) GetUsersUserIdTitles(ctx context.Context, request oapi.GetUsersU
|
||||||
return oapi.GetUsersUserIdTitles400Response{}, err
|
return oapi.GetUsersUserIdTitles400Response{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// var statuses_sort []string
|
var statuses_sort []string
|
||||||
// if request.Params.Status != nil {
|
if request.Params.Status != nil {
|
||||||
// for _, s := range *request.Params.Status {
|
for _, s := range *request.Params.Status {
|
||||||
// ss := string(s) // s type is alias for string
|
ss := string(s) // s type is alias for string
|
||||||
// statuses_sort = append(statuses_sort, ss)
|
statuses_sort = append(statuses_sort, ss)
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
watch_status, err := UserTitleStatus2Sqlc(request.Params.WatchStatus)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("%v", err)
|
|
||||||
return oapi.GetUsersUserIdTitles400Response{}, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
title_statuses, err := TitleStatus2Sqlc(request.Params.Status)
|
var watch_status []string
|
||||||
if err != nil {
|
if request.Params.WatchStatus != nil {
|
||||||
log.Errorf("%v", err)
|
for _, s := range *request.Params.WatchStatus {
|
||||||
return oapi.GetUsersUserIdTitles400Response{}, err
|
ss := string(s) // s type is alias for string
|
||||||
|
watch_status = append(statuses_sort, ss)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
params := sqlc.SearchUserTitlesParams{
|
params := sqlc.SearchUserTitlesParams{
|
||||||
Word: word,
|
Word: word,
|
||||||
TitleStatuses: title_statuses,
|
TitleStatuses: statuses_sort,
|
||||||
UsertitleStatuses: watch_status,
|
UsertitleStatuses: watch_status,
|
||||||
Rating: request.Params.Rating,
|
Rating: request.Params.Rating,
|
||||||
Rate: request.Params.MyRate,
|
Rate: request.Params.MyRate,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue