This repository is my submission for the When I Work code challenge. You can search for comments with the word "REQUIREMENT" in them to see me talk about how I approached the task.
-
You must have the .NET Core SDK 3.1 installed on your machine. The project MIGHT work with the .NET 5 SDK, but I have not tested with that version. The .NET Core version I am using is 3.1.404.
-
Clone the repo to your local machine.
-
Navigate to /backend/src on the command line
-
Run the command
dotnet run
-
Test the API with your tool of choice (Postman, Insomnia, cURL, etc.). You'll want to make requests like (substitute IDs for the IDs from the data you generate):
GET http://localhost:5000/api/shifts
GET http://localhost:5000/api/shifts/aa50d506-cbd3-4e03-aa53-4959f170ecb3
POST http://localhost:5000/api/shifts
- body:
{ "employee": "Zachary", "start": "2020-12-26T08:00:00Z", "end": "2020-12-26T16:30:00Z" }
- body:
PATCH http://localhost:5000/api/shifts/196a11d1-b81f-45a2-8bc2-f8ebfc06be39
- body:
{ "end": "2020-12-26T17:00:00Z" }
- body:
DELETE http://localhost:5000/api/shifts/8fbccc04-141e-4833-9279-3a53408b3b1d
-
You must have at least Node.js v14.15.0 installed. That's what I used in development. I'm sure it will work with newer versions and probably even v10.* but I did not test with them.
-
Navigate to /frontend in your cloned repo (from step 2 above).
-
Run the command
npm install
to install the necessary dependencies (in a different shell from the one in step 3 above). This could take a minute or two. -
Once step 3 is complete, run the command
npm run dev
. This could also take some time. You may have to continue to step 5 after a few seconds to trigger Next.js to compile the page you're trying to load. -
Navigate to
http://localhost:3000
in a browser to see the application and interact with it.
This project is hosted on my site at https://www.zachary-dunn.com/wheniwork. You should be able to use your API testing tool of choice to make requests against http://www.zachary-dunn.com/wheniwork/api/shifts, along with playing around with the app.
NOTE: For the "best" experience I recommend playing around with it locally if possible. I have never actually deployed a Next.js project before and it gave me a few problems putting it up on my site that I kinda had to piece together.
I am just using a file for storage persistence. This would never suffice for a production app, it would get very slow very quickly and you'd have to develop different mechanisms to make sure that we aren't trying to write to it from two different sources at the same time. Various database solutions (relational, nosql, etc.) provide solutions to these problems.
In a production application you would use heuristics like "no shift can be greater than 24 hours" to help limit the data further for some of these operations like checking for overlaps. That would be a helpful optimization to improve performance once the data set got large enough.