V5: Authenticated POST route to modify/submit campaigns#408
V5: Authenticated POST route to modify/submit campaigns#408elpiel merged 38 commits intoissue-382-campaign-routesfrom
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.
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.
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.
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.
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.