-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from game-node-app/dev
Dev
- Loading branch information
Showing
16 changed files
with
265 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ParsedUrlQuery } from "querystring"; | ||
import { FindStatisticsTrendingGamesDto } from "@/wrapper/server"; | ||
import period = FindStatisticsTrendingGamesDto.period; | ||
|
||
export const DEFAULT_EXPLORE_RESULT_LIMIT = 20; | ||
export const DEFAULT_EXPLORE_SCREEN_PERIOD = period.MONTH.valueOf(); | ||
|
||
export const DEFAULT_EXPLORE_TRENDING_GAMES_DTO: FindStatisticsTrendingGamesDto = | ||
{ | ||
limit: DEFAULT_EXPLORE_RESULT_LIMIT, | ||
criteria: {}, | ||
period: DEFAULT_EXPLORE_SCREEN_PERIOD as period, | ||
}; | ||
|
||
export const exploreScreenUrlQueryToDto = (query: ParsedUrlQuery) => { | ||
const dto: FindStatisticsTrendingGamesDto = structuredClone( | ||
DEFAULT_EXPLORE_TRENDING_GAMES_DTO, | ||
); | ||
for (const [k, v] of Object.entries(query)) { | ||
if (k !== "period" && typeof v === "string" && v.length > 0) { | ||
if (v.includes(",")) { | ||
//@ts-ignore | ||
dto.criteria[k] = v.split(","); | ||
} else { | ||
//@ts-ignore | ||
dto.criteria[k] = [v]; | ||
} | ||
} else if (typeof v === "string" && v.length > 0) { | ||
// @ts-ignore | ||
dto[k] = v; | ||
} | ||
} | ||
return dto; | ||
}; | ||
|
||
export const exploreScreenDtoToSearchParams = ( | ||
dto: FindStatisticsTrendingGamesDto, | ||
) => { | ||
const params = new URLSearchParams(); | ||
const { period, criteria } = dto; | ||
params.set("period", period); | ||
if (criteria) { | ||
for (const [k, v] of Object.entries(criteria)) { | ||
params.set(k, `${v}`); | ||
} | ||
} | ||
return params; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.