sendou.ink/migrations/041-plus-sixty.js
Kalle fd48bced91
Migrate Prettier/Eslint/Stylelint setup to Biome (#1772)
* Initial

* CSS lint

* Test CI

* Add 1v1, 2v2, and 3v3 Tags (#1771)

* Initial

* CSS lint

* Test CI

* Rename step

---------

Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
2024-06-24 13:07:17 +03:00

38 lines
904 B
JavaScript

export function up(db) {
db.transaction(() => {
db.prepare(`drop view "PlusVotingResult"`).run();
// same as 000-initial.js except 60% criteria
db.prepare(
/* sql */ `
create view "PlusVotingResult" as
select
"votedId",
"tier",
avg("score") as "score",
avg("score") >= 0.2 as "passedVoting",
"month",
"year",
exists (
select
1
from
"PlusSuggestion"
where
"PlusSuggestion"."month" = "PlusVote"."month"
and "PlusSuggestion"."year" = "PlusVote"."year"
and "PlusSuggestion"."suggestedId" = "PlusVote"."votedId"
and "PlusSuggestion"."tier" = "PlusVote"."tier"
) as "wasSuggested"
from
"PlusVote"
group by
"votedId",
"tier",
"month",
"year";
`,
).run();
})();
}