Skip to content

Commit

Permalink
Revert "feat: Add a new order_by option created_at (#555)" (#556)
Browse files Browse the repository at this point in the history
This reverts commit 09b14e5.
  • Loading branch information
cyaiox authored Nov 4, 2024
1 parent 09b14e5 commit c4434c4
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/entities/Place/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe(`findWithAggregates`, () => {
AND p.base_position IN (
SELECT DISTINCT(base_position) FROM "place_positions" WHERE position IN ($1)
)
ORDER BY p.created_at DESC NULLS LAST, p."deployed_at" DESC
ORDER BY p.like_score DESC NULLS LAST, p."deployed_at" DESC
LIMIT $2
OFFSET $3
`
Expand Down Expand Up @@ -218,7 +218,7 @@ describe(`findWithAggregates`, () => {
WHERE p."disabled" is false AND "world" is false AND p.base_position IN (
SELECT DISTINCT(base_position) FROM "place_positions" WHERE position IN ($3)
)
ORDER BY p.created_at DESC NULLS LAST, p."deployed_at" DESC
ORDER BY p.like_score DESC NULLS LAST, p."deployed_at" DESC
LIMIT $4
OFFSET $5
`
Expand Down Expand Up @@ -265,7 +265,7 @@ describe(`findWithAggregates`, () => {
SELECT DISTINCT(base_position) FROM "place_positions" WHERE position IN ($4)
)
ORDER BY rank DESC,
p.created_at DESC NULLS LAST, p."deployed_at" DESC
p.like_score DESC NULLS LAST, p."deployed_at" DESC
LIMIT $5
OFFSET $6
`
Expand Down Expand Up @@ -504,7 +504,7 @@ describe(`findWithHotScenes`, () => {
AND p.base_position IN (
SELECT DISTINCT(base_position) FROM "place_positions" WHERE position IN ($1)
)
ORDER BY p.created_at DESC NULLS LAST, p."deployed_at" DESC
ORDER BY p.like_score DESC NULLS LAST, p."deployed_at" DESC
LIMIT $2
OFFSET $3
`
Expand Down Expand Up @@ -606,7 +606,7 @@ describe(`findWorld`, () => {
p.disabled is false
AND world is true
AND world_name IN ($1)
ORDER BY p.created_at DESC NULLS LAST, p."deployed_at" DESC
ORDER BY p.like_score DESC NULLS LAST, p."deployed_at" DESC
LIMIT $2
OFFSET $3
`
Expand Down Expand Up @@ -652,7 +652,7 @@ describe(`findWorld`, () => {
AND world is true
AND world_name IN ($4)
AND rank > 0
ORDER BY rank DESC, p.created_at DESC NULLS LAST, p."deployed_at" DESC
ORDER BY rank DESC, p.like_score DESC NULLS LAST, p."deployed_at" DESC
LIMIT $5
OFFSET $6
`
Expand Down
4 changes: 2 additions & 2 deletions src/entities/Place/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default class PlaceModel extends Model<PlaceAttributes> {
return []
}

const orderBy = options.order_by ?? PlaceListOrderBy.LIKE_SCORE_BEST
const orderBy = PlaceListOrderBy.LIKE_SCORE_BEST
const orderDirection = oneOf(options.order, ["asc", "desc"]) ?? "desc"

const order = SQL.raw(
Expand Down Expand Up @@ -451,7 +451,7 @@ export default class PlaceModel extends Model<PlaceAttributes> {
return []
}

const orderBy = options.order_by ?? WorldListOrderBy.LIKE_SCORE_BEST
const orderBy = WorldListOrderBy.LIKE_SCORE_BEST
const orderDirection = oneOf(options.order, ["asc", "desc"]) ?? "desc"

const order = SQL.raw(
Expand Down
1 change: 0 additions & 1 deletion src/entities/Place/routes/getPlaceList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export const getPlaceList = Router.memo(
oneOf(ctx.url.searchParams.get("order_by"), [
PlaceListOrderBy.LIKE_SCORE_BEST,
PlaceListOrderBy.UPDATED_AT,
PlaceListOrderBy.CREATED_AT,
]) || PlaceListOrderBy.LIKE_SCORE_BEST,
order:
oneOf(ctx.url.searchParams.get("order"), ["asc", "desc"]) || "desc",
Expand Down
6 changes: 1 addition & 5 deletions src/entities/Place/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ export const getPlaceListQuerySchema = schema({
order_by: {
type: "string",
description: "Order places by",
enum: [
PlaceListOrderBy.LIKE_SCORE_BEST,
PlaceListOrderBy.MOST_ACTIVE,
PlaceListOrderBy.CREATED_AT,
],
enum: [PlaceListOrderBy.LIKE_SCORE_BEST, PlaceListOrderBy.MOST_ACTIVE],
nullable: true as any,
},
order: {
Expand Down
1 change: 0 additions & 1 deletion src/entities/Place/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export enum PlaceListOrderBy {
LIKE_SCORE_BEST = "like_score",
UPDATED_AT = "updated_at",
USER_VISITS = "user_visits",
CREATED_AT = "created_at",
}

export type GetPlaceListQuery = {
Expand Down
7 changes: 1 addition & 6 deletions src/entities/World/routes/getWorldList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ export const getWorldList = Router.memo(
offset: ctx.url.searchParams.get("offset"),
limit: ctx.url.searchParams.get("limit"),
only_favorites: ctx.url.searchParams.get("only_favorites"),
order_by:
oneOf(ctx.url.searchParams.get("order_by"), [
WorldListOrderBy.MOST_ACTIVE,
WorldListOrderBy.LIKE_SCORE_BEST,
WorldListOrderBy.CREATED_AT,
]) || WorldListOrderBy.MOST_ACTIVE,
order_by: WorldListOrderBy.MOST_ACTIVE,
search: ctx.url.searchParams.get("search"),
order:
oneOf(ctx.url.searchParams.get("order"), ["asc", "desc"]) || "desc",
Expand Down
6 changes: 1 addition & 5 deletions src/entities/World/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ export const getWorldListQuerySchema = schema({
order_by: {
type: "string",
description: "Order worlds by",
enum: [
WorldListOrderBy.LIKE_SCORE_BEST,
WorldListOrderBy.MOST_ACTIVE,
WorldListOrderBy.CREATED_AT,
],
enum: [WorldListOrderBy.LIKE_SCORE_BEST, WorldListOrderBy.MOST_ACTIVE],
nullable: true as any,
},
order: {
Expand Down
1 change: 0 additions & 1 deletion src/entities/World/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type GetWorldListQuery = {
export enum WorldListOrderBy {
LIKE_SCORE_BEST = "like_score",
MOST_ACTIVE = "most_active",
CREATED_AT = "created_at",
}

export type WorldListOptions = {
Expand Down

0 comments on commit c4434c4

Please sign in to comment.