-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
965 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v16.6.2 | ||
v16.13.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:16.6.2-alpine3.13 AS base | ||
FROM node:16.13.2-alpine3.15 AS base | ||
|
||
ENV NODE_ENV=production | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/backend/migration/1644010796173-convert-hard-mutes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const RE2 = require('re2'); | ||
const { MigrationInterface, QueryRunner } = require("typeorm"); | ||
|
||
module.exports = class convertHardMutes1644010796173 { | ||
name = 'convertHardMutes1644010796173' | ||
|
||
async up(queryRunner) { | ||
let entries = await queryRunner.query(`SELECT "userId", "mutedWords" FROM "user_profile"`); | ||
for(let i = 0; i < entries.length; i++) { | ||
let words = entries[i].mutedWords | ||
.map(line => { | ||
const regexp = line.join(" ").match(/^\/(.+)\/(.*)$/); | ||
if (regexp) { | ||
// convert regexp's | ||
try { | ||
new RE2(regexp[1], regexp[2]); | ||
return `/${regexp[1]}/${regexp[2]}`; | ||
} catch (err) { | ||
// invalid regex, ignore it | ||
return []; | ||
} | ||
} else { | ||
// remove empty segments | ||
return line.filter(x => x !== ''); | ||
} | ||
}) | ||
// remove empty lines | ||
.filter(x => !(Array.isArray(x) && x.length === 0)); | ||
|
||
await queryRunner.connection.createQueryBuilder() | ||
.update('user_profile') | ||
.set({ | ||
mutedWords: words | ||
}) | ||
.where('userId = :id', { id: entries[i].userId }) | ||
.execute(); | ||
} | ||
} | ||
|
||
async down(queryRunner) { | ||
let entries = await queryRunner.query(`SELECT "userId", "mutedWords" FROM "user_profile"`); | ||
for(let i = 0; i < entries.length; i++) { | ||
let words = entries[i].mutedWords | ||
.map(line => { | ||
if (Array.isArray(line)) { | ||
return line; | ||
} else { | ||
// do not split regex at spaces again | ||
return [line]; | ||
} | ||
}) | ||
// remove empty lines | ||
.filter(x => !(Array.isArray(x) && x.length === 0)); | ||
|
||
await queryRunner.connection.createQueryBuilder() | ||
.update('user_profile') | ||
.set({ | ||
mutedWords: words | ||
}) | ||
.where('userId = :id', { id: entries[i].userId }) | ||
.execute(); | ||
} | ||
} | ||
} |
Oops, something went wrong.