-
Notifications
You must be signed in to change notification settings - Fork 10
V5: Authenticated POST route to modify/submit campaigns #408
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
Conversation
sentry/src/routes/campaign.rs
Outdated
|
||
pub const CAMPAIGN_REMAINING_KEY: &'static str = "campaignRemaining"; | ||
|
||
pub async fn set_initial_remaining_for_campaign(redis: &MultiplexedConnection, id: CampaignId, amount: UnifiedNum) -> Result<bool, Error> { |
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.
Return a value that would be used to check if the Campaign id already existed in Redis. This would be another check if the campaign already exist in combination with the Postgres one.
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.
Can you clarify? Wouldn't the SETNX
return None
which would therefore return Error
if it already exists?
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.
It returns:
- 1 if the key was set (true)
- 0 if the key was not set (false)
https://redis.io/commands/setnx
If it exists we should try to insert it in Postgres as it should be already there if it's in Redis.
This shouldn't even happen as we generate a new random CampaignId when we create new campaigns (CreateCampaign) but it's good to handle this unlikely case
Issue #415 Create/Modify Campaigns - Redis and tests
sentry/src/routes/campaign.rs
Outdated
|
||
pub const CAMPAIGN_REMAINING_KEY: &'static str = "campaignRemaining"; | ||
|
||
pub async fn set_initial_remaining_for_campaign(redis: &MultiplexedConnection, id: CampaignId, amount: UnifiedNum) -> Result<bool, Error> { |
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.
It returns:
- 1 if the key was set (true)
- 0 if the key was not set (false)
https://redis.io/commands/setnx
If it exists we should try to insert it in Postgres as it should be already there if it's in Redis.
This shouldn't even happen as we generate a new random CampaignId when we create new campaigns (CreateCampaign) but it's good to handle this unlikely case
No description provided.