For fun and education
- Table of contents
- Overview
- Requirements
- How to use
- How to participate
- Function description
- Scoring
- Additional info
The first edition of Palo IT internal coding challenge. The task is to write a small piece of code.
Your solution has to be readable
, preferment
and pass provided tests
.
You need to have Node.js in reasonable version installed. (8<)
Use
npm install
to install all the dependencies.
Implement functionUnderTest
in src/functionUnderTest/index.js
file according to specs and tests.
Use
npm start
to check your solution against tests. You can also run tests in watch mode with
npm i -g jest
jest --watch
or use VSC plugin.
- Create a branch with your name eg
feature/your_name_here
. - Implement and commit your solution there. It should take you no more than 2h. Feel free to experiment with different solutions.
- When your solution is ready create a pull request to the master branch.
- Once all participants will finish everyone will take part in scoring.
The function will take the collection name (tableName
) campaign object campaign
and should return upsertCampaign()
result.
The campaign object model description:
/**
* A Slot
* @typedef {Object} Slot
* @property {string=} id - The identifier
* @property {boolean=} error determines there is an error in the slot
*
* @example { id: '22', error: false }
*/
/**
* A campaign
* @typedef {Object} Campaign
* @property {string=} id - The identifier
* @property {Date=} createdAt - The date
* @property {Slot[]} bookingSlots - The list of booking slot objects
*
* @example {id: 'qwe', createdAt: new Date(), bookingSlots: [ ... ] }
*/
- When campaign is new (ie. does not have an
id
) function needs to create it usinggenerateId()
, and add thecreatedAt
with current date. - when a slot is in error state the function needs to update it using
upsertBooking(slot, true)
- when a slot needs to be removed (the id changed to '0') the function needs to update it using
upsertBooking(slot, false)
then it has to be removed from thecampaign
and updated campaign has to be saved usingupsertCampaign(tableName, campaign)
- it there was an error performing upsert function has to return error object
{
success: false,
statusCode: 400
}
There will be two benchmarks determining the quality of your solution:
- Performance There are test that measure execution time of you method on big data sets. Lowest sum of the execution times wins. Winner gets
1 point
, second place gets2 points
etc. - Code readability Every participant will judge others' code readability. After the implementation all will go through all the branches and order them from most to least readable (NO VOTING IN YOUR OWN CODE). Again winner gets
1 point
, second place gets2 points
etc.
Finally Performance and Code readability scores will be added and the lowest score wins!!
Example
3 participants A, B, C
participant A's solution turned out to be the quickest one, but hes colleges both said his solution was least readable.
Performance: 1pt
Readability: 2pt + 2pt
Score: 5pt
If you have any questions, please contact me (Jan) or Alex