feat: migrating games to leveldb

This commit is contained in:
Chubby Granny Chaser 2025-01-19 17:59:39 +00:00
parent c115040e90
commit 1f0e195854
No known key found for this signature in database
34 changed files with 410 additions and 343 deletions

View file

@ -1,19 +1,21 @@
import { Game } from "@main/entity";
import type { Game } from "@types";
import { HydraApi } from "../hydra-api";
import { gameRepository } from "@main/repository";
import { gamesSublevel, levelKeys } from "@main/level";
export const createGame = async (game: Game) => {
return HydraApi.post(`/profile/games`, {
objectId: game.objectID,
objectId: game.objectId,
playTimeInMilliseconds: Math.trunc(game.playTimeInMilliseconds),
shop: game.shop,
lastTimePlayed: game.lastTimePlayed,
}).then((response) => {
const { id: remoteId, playTimeInMilliseconds, lastTimePlayed } = response;
gameRepository.update(
{ objectID: game.objectID },
{ remoteId, playTimeInMilliseconds, lastTimePlayed }
);
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
...game,
remoteId,
playTimeInMilliseconds,
lastTimePlayed,
});
});
};