Skip to content

Conversation

simzzz
Copy link
Contributor

@simzzz simzzz commented May 31, 2021

No description provided.

@simzzz simzzz linked an issue Jun 1, 2021 that may be closed by this pull request
24 tasks
@elpiel elpiel mentioned this pull request Jun 18, 2021
21 tasks
@simzzz simzzz marked this pull request as ready for review June 30, 2021 11:01
@simzzz simzzz requested a review from elpiel June 30, 2021 11:02
@elpiel elpiel changed the base branch from aip-61-adex-v5 to issue-382-campaign-routes July 1, 2021 04:05

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> {
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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


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> {
Copy link
Member

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

@elpiel elpiel merged commit c6c63bc into issue-382-campaign-routes Aug 9, 2021
@elpiel elpiel deleted the v5-modify-submit-campaigns branch August 9, 2021 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AIP #61 v5: Sentry POST route for inserting/modifying campaign

2 participants