wip augment TA stored data

This commit is contained in:
Tau
2019-04-29 13:50:05 -04:00
parent 1a5290a461
commit e18c2d44c5
5 changed files with 17 additions and 3 deletions

View File

@@ -143,7 +143,9 @@ create table "idz"."ta_result" (
"total_time" float not null,
"section_times" float[] not null,
"flags" smallint not null,
"grade" smallint not null
"grade" smallint not null,
"car_selector" integer not null,
"timestamp" timestamp not null,
);
create table "idz"."ta_best" (
@@ -156,6 +158,8 @@ create table "idz"."ta_best" (
"section_times" float[] not null,
"flags" smallint not null,
"grade" smallint not null, -- TODO enum
"car_selector" integer not null,
"timestamp" timestamp not null,
constraint "ta_best_uq" unique ("profile_id", "route_no")
);

View File

@@ -28,6 +28,7 @@ export class SqlTimeAttackRepository implements TimeAttackRepository {
totalTime: row.total_time,
sectionTimes: row.section_times,
grade: row.grade,
carSelector: row.car_selector,
}));
}
@@ -43,6 +44,8 @@ export class SqlTimeAttackRepository implements TimeAttackRepository {
section_times: score.sectionTimes,
flags: score.flags,
grade: score.grade,
car_selector: score.carSelector,
timestamp: score.timestamp,
})
.toParams();
@@ -68,6 +71,8 @@ export class SqlTimeAttackRepository implements TimeAttackRepository {
section_times: score.sectionTimes,
flags: score.flags,
grade: score.grade,
car_selector: score.carSelector,
timestamp: score.timestamp,
})
.toParams();
@@ -79,6 +84,8 @@ export class SqlTimeAttackRepository implements TimeAttackRepository {
section_times: score.sectionTimes,
flags: score.flags,
grade: score.grade,
car_selector: score.carSelector,
timestamp: score.timestamp,
})
.where("profile_id", profileId)
.where("route_no", score.routeNo)

View File

@@ -1,5 +1,6 @@
import { RequestCode } from "./_defs";
import { ExtId, RouteNo } from "../model/base";
import { CarSelector } from "../model/car";
import { Profile } from "../model/profile";
import { SaveTimeAttackRequest } from "../request/saveTimeAttack";
@@ -22,10 +23,10 @@ export function saveTimeAttack(buf: Buffer): SaveTimeAttackRequest {
buf.readUInt32LE(0x002c) / 1000,
],
grade: buf.readUInt8(0x0062),
carSelector: buf.readUInt16LE(0x000c) as CarSelector,
},
field_0002: buf.readUInt16LE(0x0002),
field_0008: buf.readUInt32LE(0x0008),
field_000C: buf.readUInt16LE(0x000c),
field_0012: buf.readUInt8(0x0012),
field_0015: buf.readUInt8(0x0015),
field_005D: buf.readUInt8(0x005d),

View File

@@ -1,4 +1,5 @@
import { RouteNo } from "./base";
import { CarSelector } from "./car";
export interface TimeAttackScore {
routeNo: RouteNo;
@@ -7,4 +8,5 @@ export interface TimeAttackScore {
totalTime: number;
sectionTimes: number[];
grade: number;
carSelector: CarSelector;
}

View File

@@ -1,4 +1,5 @@
import { ExtId } from "../model/base";
import { CarSelector } from "../model/car";
import { Profile } from "../model/profile";
import { TimeAttackScore } from "../model/timeAttack";
@@ -9,7 +10,6 @@ export interface SaveTimeAttackRequest {
payload: TimeAttackScore;
field_0002: number; // u16, always 1
field_0008: number; // u32
field_000C: number; // u16, car type?
field_0012: number; // u8
field_0015: number; // u8
field_005D: number; // u8