Commit 7a23de70 authored by nanahira's avatar nanahira

fix some queries and logs

parent f8965365
Pipeline #1259 passed with stages
in 10 minutes and 24 seconds
...@@ -54,7 +54,7 @@ class DataManager { ...@@ -54,7 +54,7 @@ class DataManager {
try { try {
const replays = await this.db.createQueryBuilder(CloudReplay_1.CloudReplay, "replay") const replays = await this.db.createQueryBuilder(CloudReplay_1.CloudReplay, "replay")
.where("exists (select id from cloud_replay_player where cloud_replay_player.cloudReplayId = replay.id and cloud_replay_player.key = :key)", { key }) .where("exists (select id from cloud_replay_player where cloud_replay_player.cloudReplayId = replay.id and cloud_replay_player.key = :key)", { key })
.orderBy("replay.date", "DESC") .orderBy("replay.id", "DESC")
.limit(10) .limit(10)
.leftJoinAndSelect("replay.players", "player") .leftJoinAndSelect("replay.players", "player")
.getMany(); .getMany();
......
...@@ -75,7 +75,7 @@ export class DataManager { ...@@ -75,7 +75,7 @@ export class DataManager {
try { try {
const replays = await this.db.createQueryBuilder(CloudReplay, "replay") const replays = await this.db.createQueryBuilder(CloudReplay, "replay")
.where("exists (select id from cloud_replay_player where cloud_replay_player.cloudReplayId = replay.id and cloud_replay_player.key = :key)", { key }) .where("exists (select id from cloud_replay_player where cloud_replay_player.cloudReplayId = replay.id and cloud_replay_player.key = :key)", { key })
.orderBy("replay.date", "DESC") .orderBy("replay.id", "DESC")
.limit(10) .limit(10)
.leftJoinAndSelect("replay.players", "player") .leftJoinAndSelect("replay.players", "player")
.getMany(); .getMany();
......
...@@ -45,6 +45,7 @@ __decorate([ ...@@ -45,6 +45,7 @@ __decorate([
__metadata("design:type", String) __metadata("design:type", String)
], CloudReplay.prototype, "data", void 0); ], CloudReplay.prototype, "data", void 0);
__decorate([ __decorate([
typeorm_1.Index(),
typeorm_1.Column({ type: "datetime" }), typeorm_1.Column({ type: "datetime" }),
__metadata("design:type", Date) __metadata("design:type", Date)
], CloudReplay.prototype, "date", void 0); ], CloudReplay.prototype, "date", void 0);
...@@ -53,7 +54,11 @@ __decorate([ ...@@ -53,7 +54,11 @@ __decorate([
__metadata("design:type", Array) __metadata("design:type", Array)
], CloudReplay.prototype, "players", void 0); ], CloudReplay.prototype, "players", void 0);
CloudReplay = __decorate([ CloudReplay = __decorate([
typeorm_1.Entity() typeorm_1.Entity({
orderBy: {
id: "DESC"
}
})
], CloudReplay); ], CloudReplay);
exports.CloudReplay = CloudReplay; exports.CloudReplay = CloudReplay;
//# sourceMappingURL=CloudReplay.js.map //# sourceMappingURL=CloudReplay.js.map
\ No newline at end of file
import {Column, Entity, OneToMany, PrimaryColumn} from "typeorm"; import {Column, Entity, Index, OneToMany, PrimaryColumn} from "typeorm";
import {CloudReplayPlayer} from "./CloudReplayPlayer"; import {CloudReplayPlayer} from "./CloudReplayPlayer";
import _ from "underscore"; import _ from "underscore";
import moment from "moment"; import moment from "moment";
@Entity() @Entity({
orderBy: {
id: "DESC"
}
})
export class CloudReplay { export class CloudReplay {
@PrimaryColumn({ unsigned: true, type: "bigint" }) @PrimaryColumn({ unsigned: true, type: "bigint" })
id: number; id: number;
...@@ -19,6 +23,7 @@ export class CloudReplay { ...@@ -19,6 +23,7 @@ export class CloudReplay {
return Buffer.from(this.data, "base64"); return Buffer.from(this.data, "base64");
} }
@Index()
@Column({ type: "datetime" }) @Column({ type: "datetime" })
date: Date; date: Date;
......
...@@ -50,6 +50,7 @@ __decorate([ ...@@ -50,6 +50,7 @@ __decorate([
__metadata("design:type", Number) __metadata("design:type", Number)
], DuelLog.prototype, "id", void 0); ], DuelLog.prototype, "id", void 0);
__decorate([ __decorate([
typeorm_1.Index(),
typeorm_1.Column("datetime"), typeorm_1.Column("datetime"),
__metadata("design:type", Date) __metadata("design:type", Date)
], DuelLog.prototype, "time", void 0); ], DuelLog.prototype, "time", void 0);
...@@ -83,7 +84,11 @@ __decorate([ ...@@ -83,7 +84,11 @@ __decorate([
__metadata("design:type", Array) __metadata("design:type", Array)
], DuelLog.prototype, "players", void 0); ], DuelLog.prototype, "players", void 0);
DuelLog = __decorate([ DuelLog = __decorate([
typeorm_1.Entity() typeorm_1.Entity({
orderBy: {
id: "DESC"
}
})
], DuelLog); ], DuelLog);
exports.DuelLog = DuelLog; exports.DuelLog = DuelLog;
//# sourceMappingURL=DuelLog.js.map //# sourceMappingURL=DuelLog.js.map
\ No newline at end of file
...@@ -3,11 +3,16 @@ import {DuelLogPlayer} from "./DuelLogPlayer"; ...@@ -3,11 +3,16 @@ import {DuelLogPlayer} from "./DuelLogPlayer";
import moment from "moment"; import moment from "moment";
import _ from "underscore"; import _ from "underscore";
@Entity() @Entity({
orderBy: {
id: "DESC"
}
})
export class DuelLog { export class DuelLog {
@PrimaryGeneratedColumn({unsigned: true, type: "bigint"}) @PrimaryGeneratedColumn({unsigned: true, type: "bigint"})
id: number; id: number;
@Index()
@Column("datetime") @Column("datetime")
time: Date; time: Date;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment