-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #21: Implement system for flagging typo/suspect PBs
- Loading branch information
Showing
14 changed files
with
220 additions
and
23 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
backend/functions/db/migrations/20210523145850_add_personalbest_flagged.ts
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,13 @@ | ||
import * as Knex from "knex"; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
return knex.schema.alterTable("personalBest", function (t) { | ||
t.boolean("is_flagged").notNullable().defaultTo(false); | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
return knex.schema.alterTable("personalBest", function (t) { | ||
t.dropColumn("is_flagged"); | ||
}); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { executeGiraffeql } from '~/services/giraffeql' | ||
import { handleError } from '~/services/base' | ||
|
||
export const flagPersonalBest = async (that, item) => { | ||
try { | ||
if (!that.$store.getters['auth/user']) { | ||
throw new Error('Login required') | ||
} | ||
|
||
// check for moderator | ||
if ( | ||
!['ADMIN', 'MODERATOR'].includes(that.$store.getters['auth/user'].role) | ||
) { | ||
throw new Error('Must be moderator to flag PBs') | ||
} | ||
|
||
await executeGiraffeql(that, { | ||
flagPersonalBest: { | ||
__args: { | ||
item: { | ||
id: item.id, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
that.$notifier.showSnackbar({ | ||
message: `Flagged Personal Best`, | ||
variant: 'success', | ||
}) | ||
|
||
that.reset({ | ||
resetExpanded: false, | ||
}) | ||
} catch (err) { | ||
handleError(that, err) | ||
} | ||
} |
Oops, something went wrong.