mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-29 04:50:14 +00:00
Use new museum sort order in tests
This commit is contained in:
parent
e794fccac4
commit
8cc0a1ac32
5 changed files with 18 additions and 10 deletions
|
|
@ -352,8 +352,7 @@ program
|
|||
computeMuseumOrder,
|
||||
} = arg;
|
||||
if (computeMuseumOrder) {
|
||||
const sql = fs.readFileSync("./museumOrder.sql", { encoding: "utf8" });
|
||||
await knex.raw(sql);
|
||||
await Skins.computeMuseumOrder();
|
||||
console.log("Museum order updated.");
|
||||
}
|
||||
if (configureR2Cors) {
|
||||
|
|
|
|||
|
|
@ -157,6 +157,8 @@ describe("seeded", () => {
|
|||
skin_md5: "48bbdbbeb03d347e59b1eebda4d352d0",
|
||||
error: "Whoops",
|
||||
});
|
||||
|
||||
await Skins.computeMuseumOrder();
|
||||
const page = await Skins.getMuseumPage({ offset: 0, first: 10 });
|
||||
const hasZelda = page.some(
|
||||
(skin) => skin.md5 === "48bbdbbeb03d347e59b1eebda4d352d0"
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import SkinModel from "./SkinModel";
|
|||
import UserContext from "./UserContext";
|
||||
import TweetModel from "./TweetModel";
|
||||
import { TweetStatus } from "../types";
|
||||
import fs from "fs";
|
||||
|
||||
// const CDN_URL = "https://cdn.webampskins.org";
|
||||
const CDN_URL = "https://r2.webampskins.org";
|
||||
|
|
@ -685,6 +686,16 @@ LIMIT ? OFFSET ?`,
|
|||
});
|
||||
}
|
||||
|
||||
export async function computeMuseumOrder() {
|
||||
await knex.transaction(async (trx) => {
|
||||
await trx("museum_sort_order").del();
|
||||
const sql = fs.readFileSync(path.join(__dirname, "../museumOrder.sql"), {
|
||||
encoding: "utf8",
|
||||
});
|
||||
await trx.raw(sql);
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAllClassicSkins(): Promise<
|
||||
Array<{ fileName: string; md5: string }>
|
||||
> {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,4 @@
|
|||
-- Precompute the sort order for the skin musuem.
|
||||
BEGIN IMMEDIATE TRANSACTION;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS museum_sort_order (skin_md5 TEXT references skins(md5));
|
||||
|
||||
DELETE FROM museum_sort_order;
|
||||
|
||||
INSERT INTO museum_sort_order (skin_md5)
|
||||
|
||||
-- A tweet score for each skin based on its tweets.
|
||||
|
|
@ -62,5 +56,3 @@ INSERT INTO museum_sort_order (skin_md5)
|
|||
skin_reviews.review = 'APPROVED' DESC,
|
||||
-- Skins that have been rejected are worse than those that have not been reviewed
|
||||
skin_reviews.review = 'REJECTED' ASC;
|
||||
|
||||
COMMIT;
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import * as Knex from "knex";
|
||||
import * as Skins from "../data/skins";
|
||||
|
||||
export async function seed(knex: Knex): Promise<any> {
|
||||
// Deletes ALL existing entries
|
||||
|
|
@ -9,6 +10,7 @@ export async function seed(knex: Knex): Promise<any> {
|
|||
await knex("tweets").del();
|
||||
await knex("archive_files").del();
|
||||
await knex("refreshes").del();
|
||||
await knex("museum_sort_order").del();
|
||||
// Inserts seed entries
|
||||
await knex("skins").insert([
|
||||
{ md5: "a_fake_md5", skin_type: 1, emails: "" },
|
||||
|
|
@ -56,4 +58,6 @@ export async function seed(knex: Knex): Promise<any> {
|
|||
file_date: 957771892000,
|
||||
},
|
||||
]);
|
||||
|
||||
await Skins.computeMuseumOrder();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue