idz: TA world record fixes
This commit is contained in:
@@ -11,12 +11,16 @@ import { generateId } from "../../db";
|
||||
export class SqlTimeAttackRepository implements TimeAttackRepository {
|
||||
constructor(private readonly _conn: ClientBase) {}
|
||||
|
||||
async loadTopTen(routeNo: RouteNo): Promise<TopTenResult[]> {
|
||||
async loadTopTen(
|
||||
routeNo: RouteNo,
|
||||
minTimestamp: Date
|
||||
): Promise<TopTenResult[]> {
|
||||
const loadSql = sql
|
||||
.select("p.name", "ta.*")
|
||||
.from("idz.ta_best ta")
|
||||
.join("idz.profile p", { "ta.profile_id": "p.id" })
|
||||
.where("ta.route_no", routeNo)
|
||||
.where(sql.gt("ta.timestamp", minTimestamp))
|
||||
.orderBy(["ta.total_time asc", "ta.timestamp asc"])
|
||||
.limit(10)
|
||||
.toParams();
|
||||
|
||||
@@ -16,7 +16,7 @@ export function loadTopTen1(buf: Buffer): LoadTopTenRequest {
|
||||
for (let i = 0; i < 32; i++) {
|
||||
selectors.push({
|
||||
routeNo: (buf.readUInt16LE(0x0004 + 2 * i) >> 1) as RouteNo,
|
||||
field_44: buf.readUInt32LE(0x0044 + 4 * i),
|
||||
minTimestamp: new Date(buf.readUInt32LE(0x0044 + 4 * i) * 1000 + 1000),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export function loadTopTen2(buf: Buffer): LoadTopTenRequest {
|
||||
for (let i = 0; i < 40; i++) {
|
||||
selectors.push({
|
||||
routeNo: (buf.readUInt16LE(0x0004 + 2 * i) >> 1) as RouteNo,
|
||||
field_44: buf.readUInt32LE(0x0054 + 4 * i),
|
||||
minTimestamp: new Date(buf.readUInt32LE(0x0054 + 4 * i) * 1000 + 1000),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
LoadTopTenResponseCourse,
|
||||
LoadTopTenResponseRow,
|
||||
} from "../response/loadTopTen";
|
||||
import { Repositories } from "../repo";
|
||||
import { Repositories, TopTenResult } from "../repo";
|
||||
|
||||
export async function loadTopTen(
|
||||
w: Repositories,
|
||||
@@ -17,12 +17,19 @@ export async function loadTopTen(
|
||||
break;
|
||||
}
|
||||
|
||||
if (selector.field_44 === 0) {
|
||||
const { routeNo, minTimestamp } = selector;
|
||||
let src: TopTenResult[];
|
||||
|
||||
if (req.teamId !== undefined) {
|
||||
src = []; // TODO
|
||||
} else {
|
||||
src = await w.timeAttack().loadTopTen(routeNo, minTimestamp);
|
||||
}
|
||||
|
||||
if (src.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const { routeNo } = selector;
|
||||
const src = await w.timeAttack().loadTopTen(routeNo);
|
||||
const dest = new Array<LoadTopTenResponseRow>();
|
||||
|
||||
for (const srcItem of src) {
|
||||
|
||||
+4
-1
@@ -72,7 +72,10 @@ export interface TopTenResult {
|
||||
}
|
||||
|
||||
export interface TimeAttackRepository {
|
||||
loadTopTen(routeNo: Model.RouteNo): Promise<TopTenResult[]>;
|
||||
loadTopTen(
|
||||
routeNo: Model.RouteNo,
|
||||
minTimestamp: Date
|
||||
): Promise<TopTenResult[]>;
|
||||
|
||||
loadAll(
|
||||
profileId: Model.ExtId<Model.Profile>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Team } from "../model/team";
|
||||
|
||||
export interface LoadTopTenRequestSelector {
|
||||
routeNo: RouteNo;
|
||||
field_44: number;
|
||||
minTimestamp: Date;
|
||||
}
|
||||
|
||||
export interface LoadTopTenRequest {
|
||||
|
||||
Reference in New Issue
Block a user