-
Notifications
You must be signed in to change notification settings - Fork 8
feat: settings in seed #682
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c95f532
refactor: move const settings objects into constants file
pierreTklein 0e093c9
feat: add settings to seed script
pierreTklein 1f110a2
fix: update settings schema defaults so that they are more sensible, …
pierreTklein 7da1d5e
Merge branch 'dev' into feat/678-settings-in-seed
chenxuan-zhou dd6b5ef
Merge branch 'dev' into feat/678-settings-in-seed
chenxuan-zhou c7a580d
fix: export and use settings constants
chenxuan-zhou b0bb221
Merge branch 'dev' into feat/678-settings-in-seed
chenxuan-zhou 836f5cf
Merge remote-tracking branch 'origin/dev' into feat/678-settings-in-seed
jamesxu123 90406f4
fix: import setting constants directly in test
chenxuan-zhou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,39 @@ | ||
| const APP_NOT_YET_OPEN = { | ||
| openTime: new Date(Date.now() + 100000000000), | ||
| closeTime: new Date(Date.now() + 10000000000000000), | ||
| confirmTime: new Date(Date.now() + 100000000000000000) | ||
| }; | ||
|
|
||
| const APP_OPEN = { | ||
| openTime: new Date(Date.now() - 100), | ||
| closeTime: new Date(Date.now() + 10000000000), | ||
| confirmTime: new Date(Date.now() + 100000000000000) | ||
| }; | ||
|
|
||
| const APP_CLOSED = { | ||
| openTime: new Date(Date.now() - 100), | ||
| closeTime: new Date(Date.now() - 1000), | ||
| confirmTime: new Date(Date.now() + 100000000000000) | ||
| }; | ||
|
|
||
| const CONFIRM_CLOSED = { | ||
| openTime: new Date(Date.now() - 10000), | ||
| closeTime: new Date(Date.now() - 1000), | ||
| confirmTime: new Date(Date.now() - 100) | ||
| }; | ||
|
|
||
| const REMOTE_HACKATHON = { | ||
| openTime: new Date(Date.now() - 100), | ||
| closeTime: new Date(Date.now() + 10000000000), | ||
| confirmTime: new Date(Date.now() + 100000000000000), | ||
| isRemote: true | ||
| }; | ||
|
|
||
| // Some utility dates that are used in tests and seed script | ||
| module.exports = { | ||
| APP_NOT_YET_OPEN: APP_NOT_YET_OPEN, | ||
| APP_OPEN: APP_OPEN, | ||
| APP_CLOSED: APP_CLOSED, | ||
| CONFIRM_CLOSED: CONFIRM_CLOSED, | ||
| REMOTE_HACKATHON: REMOTE_HACKATHON | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,22 @@ | ||
| "use strict"; | ||
| const Settings = require("../models/settings.model"); | ||
|
|
||
| /** | ||
| * Drops all elements in Role | ||
| */ | ||
| function drop() { | ||
| return Settings.deleteMany({}); | ||
| } | ||
|
|
||
| /** | ||
| * Stores all of the roles in the db | ||
| * @param {Settings} setting the setting that we want to seed | ||
| */ | ||
| function store(setting) { | ||
| return Settings.collection.insertOne(new Settings(setting)); | ||
| } | ||
|
|
||
| module.exports = { | ||
| store: store, | ||
| drop: drop | ||
| }; |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it'd be a good idea to have it default to a day before Date.now()?
Only time I can think of were we should be using defaults is for local environment and applications open is probably most useful state for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set it 1mo from now for production reasons. I wouldn't want the API to be able to accept applications right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other time we use defaults is when you create a new DB for production (which may or may not happen, but it could).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's fair