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

Add status field to Orders #1391

Merged
merged 4 commits into from
Aug 1, 2018
Merged

Add status field to Orders #1391

merged 4 commits into from
Aug 1, 2018

Conversation

HipsterBrown
Copy link
Contributor

To facilitate creating pledges for collectives (see opencollective/opencollective#1168), this PR adds a status field to Orders:

  • PENDING (default)
  • PAID (one-time completed orders)
  • ACTIVE (subscriptions)
  • CANCELLED
  • REJECTED
  • ERROR

The migration also includes code to update existing Orders.

@@ -0,0 +1,125 @@
'use strict';
import status from '../server/constants/order_status';
Copy link
Member

@znarf znarf Aug 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note, we ave several style in this code base for naming files, would be great to pick one (order_status vs order-status vs orderStatus).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I used this convention to match the expense_status.js file. I'll create an issue to standardize this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After having looked at several repositories, looks like the current common practice is ... hyphen case! So that would be order-status. Anyway, let's take care of that later.

if (!orderCreated.processedAt) {
// TODO: Order should be updated with data JSON field to store the error to review later
orderCreated.update({ status: status.ERROR });
}
throw e;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to throw the error as you're already inside the catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it was thrown again to bubble it back up to the graphql response, otherwise the frontend never sees the error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it! LGTM then..

Copy link
Contributor

@marcogbarcellos marcogbarcellos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rock solid!
I agree with @znarf about having a standard to name files but it doesn't mean order_status.js may go with the standard, so it's all good here!

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 71.156% when pulling b2a9f0c on order-status into db778be on master.

@arnaudbenard arnaudbenard temporarily deployed to opencollective-staging-api August 1, 2018 20:18 Inactive
@HipsterBrown HipsterBrown merged commit 7808074 into master Aug 1, 2018
@HipsterBrown HipsterBrown deleted the order-status branch August 1, 2018 20: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.

None yet

5 participants