-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1148 from givepraise/add/direct-praise-quantifica…
…tion Add/direct praise quantification
- Loading branch information
Showing
11 changed files
with
177 additions
and
24 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
Large diffs are not rendered by default.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...s/api/src/database/migrations/43_settings_add_discord_bot_direct_praise_quantification.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,36 @@ | ||
import { SettingGroup } from '../../settings/enums/setting-group.enum'; | ||
import { SettingModel } from '../schemas/settings/23_settings.schema'; | ||
|
||
const settings = [ | ||
{ | ||
key: 'DISCORD_BOT_DIRECT_PRAISE_QUANTIFICATION_ENABLED', | ||
value: false, | ||
defaultValue: false, | ||
type: 'Boolean', | ||
periodOverridable: false, | ||
label: 'Direct praise quantification', | ||
description: | ||
'Enabling this will allow the praise giver to quantify their praise directly at the time of praising. Enabling this will disable and bypass the regular praise quantification flow.', | ||
group: SettingGroup.DISCORD, | ||
subgroup: 1, | ||
}, | ||
]; | ||
|
||
const up = async (): Promise<void> => { | ||
const settingUpdates = settings.map((s) => ({ | ||
updateOne: { | ||
filter: { key: s.key }, | ||
update: { $setOnInsert: { ...s } }, // Insert setting if not found, otherwise continue | ||
upsert: true, | ||
}, | ||
})) as any; | ||
|
||
await SettingModel.bulkWrite(settingUpdates); | ||
}; | ||
|
||
const down = async (): Promise<void> => { | ||
const allKeys = settings.map((s) => s.key); | ||
await SettingModel.deleteMany({ key: { $in: allKeys } }); | ||
}; | ||
|
||
export { up, down }; |
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