mirror of
https://github.com/djhackersdev/minime.git
synced 2026-08-20 09:24:21 -05:00
wip load/save doesn't crash
This commit is contained in:
@@ -12,7 +12,7 @@ export class SqlCharaRepository implements FacetRepository<Chara> {
|
||||
|
||||
async load(extId: ExtId<Profile>): Promise<Chara> {
|
||||
const loadSql = sql
|
||||
.select("s.*")
|
||||
.select("c.*")
|
||||
.from("idz.profile p")
|
||||
.join("idz.chara c", { "p.id": "c.id" })
|
||||
.where("p.ext_id", extId)
|
||||
|
||||
@@ -18,7 +18,7 @@ export class SqlCoursePlaysRepository implements CoursePlaysRepository {
|
||||
.where("p.ext_id", extId)
|
||||
.toParams();
|
||||
|
||||
const { rows } = await this._conn.query(sql);
|
||||
const { rows } = await this._conn.query(loadSql);
|
||||
const result = new Map();
|
||||
|
||||
for (const row of rows) {
|
||||
@@ -43,7 +43,8 @@ export class SqlCoursePlaysRepository implements CoursePlaysRepository {
|
||||
count: v,
|
||||
})
|
||||
.onConflict("profile_id", "course_no")
|
||||
.doUpdate(["count"]);
|
||||
.doUpdate(["count"])
|
||||
.toParams();
|
||||
|
||||
await this._conn.query(saveSql);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ export class SqlMissionsRepository implements FacetRepository<MissionState> {
|
||||
extId: ExtId<Profile>
|
||||
): Promise<[MissionState, Id<Profile>]> {
|
||||
const result: MissionState = {
|
||||
team: new Array<MissionGrid>(),
|
||||
solo: new Array<MissionGrid>(),
|
||||
team: new Array<MissionGrid>(),
|
||||
};
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
@@ -27,6 +27,9 @@ export class SqlMissionsRepository implements FacetRepository<MissionState> {
|
||||
soloGrid.cells.push(0);
|
||||
teamGrid.cells.push(0);
|
||||
}
|
||||
|
||||
result.solo.push(soloGrid);
|
||||
result.team.push(teamGrid);
|
||||
}
|
||||
|
||||
const profileId = await _findProfile(this._conn, extId);
|
||||
@@ -65,7 +68,7 @@ export class SqlMissionsRepository implements FacetRepository<MissionState> {
|
||||
}
|
||||
|
||||
const saveSql = sql
|
||||
.insert("idz.mission_state", {
|
||||
.insert("idz.solo_mission_state", {
|
||||
id: generateId(),
|
||||
profile_id: profileId,
|
||||
grid_no: i,
|
||||
|
||||
@@ -29,7 +29,7 @@ export class SqlProfileRepository implements ProfileRepository {
|
||||
aimeId: AimeId
|
||||
): Promise<Profile | undefined> {
|
||||
const lookupSql = sql
|
||||
.select("p.id")
|
||||
.select("p.*")
|
||||
.from("idz.profile p")
|
||||
.join("aime.player r", { "p.player_id": "r.id" })
|
||||
.where("r.ext_id", aimeId)
|
||||
|
||||
@@ -14,7 +14,7 @@ export class SqlTimeAttackRepository implements TimeAttackRepository {
|
||||
async loadAll(extId: ExtId<Profile>): Promise<TimeAttackScore[]> {
|
||||
const loadSql = sql
|
||||
.select("ta.*")
|
||||
.from("idz.time_attack ta")
|
||||
.from("idz.ta_best ta")
|
||||
.join("idz.profile p", { "ta.profile_id": "p.id" })
|
||||
.where("p.ext_id", extId)
|
||||
.toParams();
|
||||
|
||||
Reference in New Issue
Block a user