Fix GET /works
This commit is contained in:
parent
d76d8a4fce
commit
5a6390e9a5
8
works.go
8
works.go
@ -17,11 +17,11 @@ func init() {
|
||||
router.GET("/api/works", apiAuthHandler(
|
||||
func(u *User, _ httprouter.Params, _ []byte) HTTPResponse {
|
||||
if u == nil {
|
||||
return formatApiResponse(getWorks(fmt.Sprintf("WHERE (shown = TRUE OR direct IS NOT NULL) AND NOW() > start_availability AND promo = %d ORDER BY start_availability ASC", currentPromo)))
|
||||
return formatApiResponse(getWorks(fmt.Sprintf("WHERE shown = TRUE AND NOW() > start_availability AND promo = %d ORDER BY start_availability ASC", currentPromo)))
|
||||
} else if u.IsAdmin {
|
||||
return formatApiResponse(getWorks("ORDER BY promo DESC, start_availability ASC"))
|
||||
} else {
|
||||
works, err := getWorks(fmt.Sprintf("WHERE (shown = TRUE OR direct IS NOT NULL) AND promo = %d ORDER BY start_availability ASC", u.Promo))
|
||||
works, err := getWorks(fmt.Sprintf("WHERE shown = TRUE AND promo = %d ORDER BY start_availability ASC", u.Promo))
|
||||
if err != nil {
|
||||
return APIErrorResponse{err: err}
|
||||
}
|
||||
@ -40,11 +40,11 @@ func init() {
|
||||
router.GET("/api/all_works", apiAuthHandler(
|
||||
func(u *User, _ httprouter.Params, _ []byte) HTTPResponse {
|
||||
if u == nil {
|
||||
return formatApiResponse(allWorks(fmt.Sprintf("WHERE (shown = TRUE OR direct IS NOT NULL) AND NOW() > start_availability AND promo = %d ORDER BY start_availability ASC", currentPromo)))
|
||||
return formatApiResponse(allWorks(fmt.Sprintf("WHERE (shown = TRUE OR direct IS NOT NULL) AND NOW() > start_availability AND promo = %d ORDER BY start_availability ASC, end_availability ASC", currentPromo)))
|
||||
} else if u.IsAdmin {
|
||||
return formatApiResponse(allWorks("ORDER BY promo DESC, start_availability ASC"))
|
||||
} else {
|
||||
works, err := allWorks(fmt.Sprintf("WHERE (shown = TRUE OR direct IS NOT NULL) AND promo = %d ORDER BY start_availability ASC", u.Promo))
|
||||
works, err := allWorks(fmt.Sprintf("WHERE (shown = TRUE OR direct IS NOT NULL) AND promo = %d ORDER BY start_availability ASC, end_availability ASC", u.Promo))
|
||||
if err != nil {
|
||||
return APIErrorResponse{err: err}
|
||||
}
|
||||
|
Reference in New Issue
Block a user