Commit 26b46c91 authored by nanahira's avatar nanahira

add missing index

parent 8a2450c5
Pipeline #1232 passed with stage
in 7 minutes and 28 seconds
...@@ -80,10 +80,11 @@ class DataManager { ...@@ -80,10 +80,11 @@ class DataManager {
.select(`${minOrMax}(id)`, "value") .select(`${minOrMax}(id)`, "value")
.from(CloudReplay_1.CloudReplay, "replay") .from(CloudReplay_1.CloudReplay, "replay")
.getRawOne())); .getRawOne()));
if (!minQuery || maxQuery) { if (!minQuery || !maxQuery) {
return null; return null;
} }
const targetId = Math.floor((maxQuery.value - minQuery.value) * Math.random()) + minQuery.value; const [maxId, minId] = [minQuery, maxQuery].map(query => parseInt(query.value));
const targetId = Math.floor((maxId - minId) * Math.random()) + minId;
return await this.db.createQueryBuilder(CloudReplay_1.CloudReplay, "replay") return await this.db.createQueryBuilder(CloudReplay_1.CloudReplay, "replay")
.where("replay.id >= :targetId", { targetId }) .where("replay.id >= :targetId", { targetId })
.orderBy("replay.id", "ASC") .orderBy("replay.id", "ASC")
......
...@@ -31,6 +31,7 @@ __decorate([ ...@@ -31,6 +31,7 @@ __decorate([
__metadata("design:type", Number) __metadata("design:type", Number)
], VipKey.prototype, "type", void 0); ], VipKey.prototype, "type", void 0);
__decorate([ __decorate([
typeorm_1.Index(),
typeorm_1.Column("tinyint", { unsigned: true, default: 0 }), typeorm_1.Column("tinyint", { unsigned: true, default: 0 }),
__metadata("design:type", Number) __metadata("design:type", Number)
], VipKey.prototype, "isUsed", void 0); ], VipKey.prototype, "isUsed", void 0);
......
...@@ -13,6 +13,7 @@ export class VipKey { ...@@ -13,6 +13,7 @@ export class VipKey {
@Column("int", {unsigned: true}) @Column("int", {unsigned: true})
type: number; type: number;
@Index()
@Column("tinyint", {unsigned: true, default: 0}) @Column("tinyint", {unsigned: true, default: 0})
isUsed: number; isUsed: number;
......
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