Skip to content

Commit 068888c

Browse files
committed
sort by age is possible now
1 parent cb3ddac commit 068888c

6 files changed

Lines changed: 97 additions & 11 deletions

File tree

bun.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gameidtime.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
BloonsTowerDefense5 game_cf40_bc827595acce8
2+
OvO game_a1c4_5e86a51943679 October 8, 2024
3+
RiddleTransfer2 game_1808_fce44508ce0a4
4+
RiddleTransfer game_750a_9bdf571e2e46d
5+
IdleDice game_c411_d5ac57bea9aaa
6+
MotoX3m game_a62c_54ae0a6a4d838
7+
Minecraft1.12WASM game_867c_8d6e65b171f1d
8+
ThereIsNoGame game_d477_98eb499d8f347 October 8, 2024

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@aws-sdk/credential-provider-cognito-identity": "^3.883.0",
6060
"@aws-sdk/util-dynamodb": "^3.883.0",
6161
"@sveltejs/adapter-static": "^3.0.9",
62+
"@types/node": "^24.7.2",
6263
"fs": "^0.0.1-security"
6364
}
6465
}

parsegameidtime.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import * as fsp from 'fs/promises';
2+
import * as fs from 'fs';
3+
import { exec, execSync } from 'child_process';
4+
import { timeStamp } from 'console';
5+
6+
async function main () {
7+
const file = "gameidtime.txt";
8+
9+
const content = await fsp.readFile(file, { encoding: "utf8" });
10+
const rows = content.split("\n");
11+
const games = rows.map(g => {
12+
g = g.trim();
13+
const sections = g.split(" ");
14+
const [gameName, gameID, ...gameTime] = sections;
15+
let gameDate = new Date(gameTime.join(" "));
16+
if (isNaN(gameDate.getTime())){
17+
gameDate = new Date("March 9, 2025")
18+
}
19+
return {
20+
gameName,
21+
gameID,
22+
gameDate
23+
}
24+
});
25+
26+
let workingGames = games.filter(g => !isNaN(g.gameDate.getTime())).sort((a, b) => a.gameDate.getTime() - b.gameDate.getTime());
27+
28+
29+
const command = (gameID: string, timestamp: number) => {
30+
fs.writeFileSync("values.json", JSON.stringify({ ":u": { "N": `${timestamp}` } }))
31+
fs.writeFileSync("key.json", JSON.stringify({ "gameID": { "S": gameID } }));
32+
return `aws dynamodb update-item
33+
--table-name games_list
34+
--key file://key.json
35+
--update-expression "SET uploadedTimestamp = :u, updatedTimestamp = :u"
36+
--expression-attribute-values file://values.json`
37+
}
38+
39+
let lastTime = 0;
40+
let inc = 0;
41+
workingGames.forEach(game => {
42+
let add = lastTime == game.gameDate.getTime() ? ++inc : (inc = 0);
43+
lastTime = game.gameDate.getTime();
44+
let c = command(game.gameID, game.gameDate.getTime() + add);
45+
console.log(">>>>", c);
46+
execSync(c.split("\n").map(s => s.trim()).join(" "));
47+
console.log("Finished", game.gameName)
48+
})
49+
}
50+
51+
main().then(() => {
52+
console.log("\n\nDone")
53+
}).catch(console.error)

src/lib/components/CardGrid.svelte

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@
3737
};
3838
3939
// Sort options
40-
type SortType = "default" | "az" | "za" | "clicksAsc" | "clicksDesc";
40+
type SortType = "default" | "az" | "za" | "clicksAsc" | "clicksDesc" | "new" | "old";
4141
let sortType = $state<SortType>("default");
4242
4343
function getSortedGames() {
4444
let sorted = [...games];
4545
switch (sortType) {
46+
case "new":
47+
sorted.sort((a, b) => b.uploadedTimestamp - a.uploadedTimestamp);
48+
break;
49+
case "old":
50+
sorted.sort((a, b) => a.uploadedTimestamp - b.uploadedTimestamp);
51+
break;
4652
case "az":
4753
sorted.sort((a, b) => a.fName.localeCompare(b.fName));
4854
break;
@@ -389,6 +395,9 @@
389395
<option value="za">Z → A</option>
390396
<option value="clicksAsc">Clicks ↑</option>
391397
<option value="clicksDesc">Clicks ↓</option>
398+
<option value="new">Newest</option>
399+
<option value="old">Oldest</option>
400+
392401
</select>
393402
<button
394403
class="choose-for-me"

src/lib/components/GameCard.svelte

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@
55
66
import type { Game } from "../types/game.ts";
77
8-
const { game, i, tagClick, commitHash }: { game: Game; i: number, tagClick: (tag: string) => void, commitHash: string } = $props();
8+
const {
9+
game,
10+
i,
11+
tagClick,
12+
commitHash,
13+
}: {
14+
game: Game;
15+
i: number;
16+
tagClick: (tag: string) => void;
17+
commitHash: string;
18+
} = $props();
919
const {
1020
gameID,
1121
thumbPath,
@@ -17,13 +27,11 @@
1727
updatedTimestamp,
1828
} = game;
1929
20-
21-
let normalThumbPath = `https://cdn.jsdelivr.net/gh/ccported/games@${commitHash}/${gameID}${thumbPath}`
30+
let normalThumbPath = `https://cdn.jsdelivr.net/gh/ccported/games@${commitHash}/${gameID}${thumbPath}`;
2231
let starred = $state(State.pinnedGames.includes(gameID) ? true : false);
2332
2433
let cardElement: HTMLDivElement;
25-
let isHovered = $state(false);
26-
34+
let isHovered = $state(false);
2735
2836
function togglePin(e: MouseEvent | KeyboardEvent) {
2937
e.stopPropagation();
@@ -48,7 +56,6 @@
4856
let show: "" | " (Updated)" | " (New)" =
4957
isUpdated && !isNew ? " (Updated)" : isNew ? " (New)" : "";
5058
51-
5259
function handleMouseMove(e: MouseEvent) {
5360
if (!cardElement) return;
5461
@@ -85,7 +92,7 @@
8592

8693
<div
8794
class="card-wrapper"
88-
style="position: relative; animation-delay: {(i < 25) ? i * 75 : 75 * 25}ms"
95+
style="position: relative; animation-delay: {i < 25 ? i * 75 : 75 * 25}ms"
8996
class:new={isNew || isUpdated}
9097
class:starred
9198
>
@@ -106,7 +113,10 @@
106113
class:hovered={isHovered}
107114
id={gameID}
108115
aria-label="Open game"
109-
onclick={() => {openGame(game)}}
116+
onclick={() => {
117+
// navigator.clipboard.writeText(gameID);
118+
openGame(game);
119+
}}
110120
onkeydown={(e) => {
111121
if (e.key === "Enter" || e.key === " ") openGame(game);
112122
}}
@@ -134,8 +144,8 @@
134144
onclick={(e) => {
135145
e.stopPropagation();
136146
tagClick(tag as string);
137-
}}
138-
>{decamelize(tag as string)}</button>
147+
}}>{decamelize(tag as string)}</button
148+
>
139149
{/each}
140150
</div>
141151
</div>

0 commit comments

Comments
 (0)