Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/option assign all quantifiers #456

Merged
merged 14 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Export the user list as csv #402 #450
- Option to turn on/off the Discord role requirement for Praise givers #419 #434 #440
- Support multiple wallets: WalletConneect, Trust, Rainbow etc #424
- Option to assign praise evenly between all quantifiers #263
- More verbose output from the `/admin announce` command #317 #441

### Fixed
Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"express-async-errors": "^3.1.1",
"express-fileupload": "^1.3.1",
"faker": "^5.5.3",
"greedy-number-partitioning": "https://github.com/mattyg/greedy-number-partitioning.git",
"helmet": "^4.6.0",
"http-status-codes": "^2.1.4",
"jet-logger": "^1.1.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { SettingGroup } from '@settings/types';
import { SettingsModel } from '@settings/entities';
import { PeriodSettingsModel } from '@periodsettings/entities';
import { PeriodModel } from '@period/entities';
import { PeriodDocument } from '@period/types';

const newSetting = {
key: 'PRAISE_QUANTIFIERS_ASSIGN_ALL',
value: false,
type: 'Boolean',
label: 'Assign praise to all quantifiers',
description:
'Evenly assign praise among all quantifiers. If enabled, the setting "Quantifiers Per Praise" will be ignored',
group: SettingGroup.PERIOD_DEFAULT,
};

const up = async (): Promise<void> => {
await SettingsModel.create(newSetting);

const periods = await PeriodModel.find({});
const periodsettings = periods.map((p: PeriodDocument) => ({
...newSetting,
period: p._id,
}));

await PeriodSettingsModel.insertMany(periodsettings);
};

const down = async (): Promise<void> => {
await SettingsModel.deleteMany({ key: newSetting.key });
await PeriodSettingsModel.deleteMany({ key: newSetting.key });
};

export { up, down };
Loading