-
Notifications
You must be signed in to change notification settings - Fork 20
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
Feat/web api missing functions #69
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #69 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 19 23 +4
Lines 164 210 +46
Branches 31 38 +7
=========================================
+ Hits 164 210 +46
Continue to review full report at Codecov.
|
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.
looks good to me, these functionally are needed for a web server where you have enpoints such as
.../api/Wilayas/{wilayaCode}/Daira/{dairaCode}/Baladiya/{baladiyaCode}
the code itself looks good.
The only thing missing is updating the readme documentation, can you please do that @abderrahmaneMustapha
@ZibanPirate done , i updated the documentation |
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.
Thanks man for your great efforts! I just got some comments (please don't hate me).
Also, please next time file an issue before started working on such features just to keep track of our changes, aaaand please it would be easier for us to review small PRs as you know, so it'd be ideal to work on each feature on a small PR which should be linked to our issue.
* @param { String[] } projection a list of Baladyia object attributes to keep | ||
* @returns { Object | null } Returns a baldiya's object, or null | ||
*/ | ||
(mattricule, code, bcode, projection)=>{ |
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.
Please fix linting issues
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.
I liked everything and learned a lot from it 😁; there is no cause to dislike you, and thank you very much for your valuable feedbacks.
* @param { integer } mattricule wilaya mattricule | ||
* @param { integer } code daira code | ||
* @param { integer } bcode baladiya code |
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.
Do you mean?
* @param { integer } mattricule wilaya mattricule | |
* @param { integer } code daira code | |
* @param { integer } bcode baladiya code | |
* @param { number } mattricule wilaya mattricule | |
* @param { number } code daira code | |
* @param { number } bcode baladiya code |
@@ -0,0 +1,31 @@ | |||
const projectBaladiya = require('../utils/projections/projectObject'); | |||
|
|||
const getBaladiyaByCodeAndDairaCodeAndWilayaCode = (data) => |
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.
Please do you have any use case for such a feature? I believe that Baladyia code is unique overall, so if you'd use it it won't matter to add extra params. And if you want to get a baladyia by wilaya or daira code you'd just use their methods with a projection
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 please explain how can i get the same result by using projection
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.
We do have these methods in place:
const {
getBaladyiatsForWilaya,
getBaladyiatsForDaira
} = require("@dzcode-io/leblad");
const rs1 = getBaladyiatsForWilaya(31); // if this wasn't implemented, we'd use getWilayaByCode and project only "dairats"
const rs2 = getBaladyiatsForDaira("ORAN");
Maybe it'd be nice to have another getBaladyiatsForDairaCode
method. If you want to create it, please do it on a separate PR, based on develop
@@ -0,0 +1,38 @@ | |||
const projectBaladiya = require('../utils/projections/projectObject'); | |||
|
|||
const getBaldiyaByCodeForWilaya = (data) => |
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.
I'd name it getBaladyiaByWilayaCode
. But again, why we don't just use getWilayaByCode
then call the projection.
* @param { Number } mattricule wilaya code (mattricule) | ||
* @param { Number } code baladiya code (code) |
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.
Please check jsdoc
here and in all changed files
* @param { Number } mattricule wilaya code (mattricule) | |
* @param { Number } code baladiya code (code) | |
* @param { number } mattricule wilaya code (mattricule) | |
* @param { number } code baladiya code (code) |
@@ -0,0 +1,31 @@ | |||
const projectBaladiya = require('../utils/projections/projectObject'); | |||
|
|||
const getBaldiyatsForDairaByCodeForWilayaByCode = (data) => |
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.
Same as my previous comments, plus this name can be simplified to getBaldiyatsByWilayaCode
or getBaldiyatsByDairaCode
. And if you could find a counterexample/argument to keep such composed methods which means that daira code is not enough to identify wilayas. we can name this: getBaldiyatsByWilayaAndDairaCodes
const getDairaByCodeAndWilayaCode = require('./api/getDairaByCodeAndWilayaCode'); | ||
const getBaladiyaByCodeAndDairaCodeAndWilayaCode = require('./api/getBaladiyaByCodeAndDairaCodeAndWilayaCode'); | ||
const getBaldiyatsForDairaByCodeForWilayaByCode = require('./api/getBaldiyatsForDairaByCodeForWilayaByCode'); | ||
const getBaldiyaByCodeForWilaya = require('./api/getBaldiyaByCodeForWilaya'); | ||
const data = require('../data/WilayaList.json'); |
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.
I'd leave a blank line before the dataset import just for the sake of clarity and readablity
|
||
|
||
|
||
it('should export a function', () => { |
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.
Please apply the linter+prettier to remove such whitespaces and to add an empty line at EOF
Description
i added some missing functions , that i need to use in leblad web api
Checklist:
npm run update-dataset
)npm test
passes on my machinenpm run lint
passes on my machine