Skip to content

Conversation

@logan-r
Copy link
Member

@logan-r logan-r commented Jan 14, 2020

Tickets:

  • HCK-

List of changes:

Create a travel model and api. Model is of form

{
  _id: ObjectId // The id of the travel document
  hackerId: ObjectId // The id of the hacker that is traveling
  accountId: ObjectId // The id of the user that is traveling
  request: number // The amount of money the hacker is requesting for travel
  offer: number // The amount of money we are giving the hacker for travel
  status: string // The state of the hacker's travel request
}

Following api end points were also created:

  • GET /travel/:id gets a travel with a certain id
  • GET /travel/self gets travel associated with the logged in user
  • GET /travel/email/:email gets the travel associated with the user of a given email
  • POST /travel creates a new travel
  • PATCH /travel/status/:id updates the status field of a given traveler
  • PATCH /travel/offer/:id updates the amount of money we are offering a given traveler

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

Firmware version:
Hardware:
Toolchain:
SDK:

Questions for code reviewers?

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Listed change(s) in the Changelog
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

@logan-r logan-r requested a review from loreina January 14, 2020 15:12
}
});
}
req.body.travelDetails.request = hacker.application.accommodation.travel;

Choose a reason for hiding this comment

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

return next()?

* @param {JSON} res
* @param {(err?)=>void} next
* @return {void}
* @description Load travel request from hacker application and add it to

Choose a reason for hiding this comment

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

Nit: add it to req.body.travelDetails

const travelDetails = req.body.travelDetails;

const exists = await Services.Hacker.findByAccountId(
travelDetails.accountId

Choose a reason for hiding this comment

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

Need to change this to instead look for a travel record by accountID instead to ensure we don't make duplicate travel docs for same linked accs. The way it is now, it is just looking for a hacker associated to an accountID which is not what we want I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

True true

@logan-r logan-r requested a review from printharsh January 14, 2020 17:01
Copy link
Member

@loreina loreina left a comment

Choose a reason for hiding this comment

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

LGTM! functionality seems great

@MrHarshPatel if it's good on the technical side, ready to merge

post: {
requestType: Constants.REQUEST_TYPES.POST,
uri: "/api/travel/"
},
Copy link
Member

Choose a reason for hiding this comment

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

what is this post? Did you mean create travel?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's for create - thought I was following the naming convention from account and hacker, would it be better to rename this from post to createTravel?

function updatedTravel(req, res) {
return res.status(200).json({
message: Constants.Success.TRAVEL_UPDATE,
data: req.body
Copy link
Member

Choose a reason for hiding this comment

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

Should this be json like the other portions or no?

Error: require("../constants/error.constant")
};

function okay(req, res) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: okay sounds a bit odd as a function name

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, this function was just for debugging - I'll remove it

function addDefaultStatusAndOffer(req, res, next) {
req.body.travelDetails.status = "None";
req.body.travelDetails.offer = 0;
return next();
Copy link
Member

Choose a reason for hiding this comment

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

Can this be added in parseTravel? or is this used for a specific purpose?

@logan-r logan-r merged commit 0040e20 into develop Jan 14, 2020
@logan-r logan-r deleted the create-travel-api branch January 14, 2020 22:44
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.

6 participants