Skip to content

Instantly share code, notes, and snippets.

@billybonks
Created September 3, 2019 05:23
Show Gist options
  • Save billybonks/e92b1281fe7c4eeb4ffa4555da951c19 to your computer and use it in GitHub Desktop.
Save billybonks/e92b1281fe7c4eeb4ffa4555da951c19 to your computer and use it in GitHub Desktop.

Build an application that consumes/accepts a CSV (Comma Separated Values) file of N-Rows. Each Row is comprised of:

  • object_id: is a unique identifier for a specific object.
  • object_type: denotes the object type.
  • timestamp: needs no explanation
  • object_changes: serialized json comprised of properties that changed at timestamp, and their accompanying values.

Here's an example CSV:

object_id,object_type,timestamp,object_changes
1,Order,1484730554,"{\"customer_name\":\"Jack\",\"customer_address\":\"Trade St.\",\"status\":\"unpaid\"}"
2,Order,1484730623,"{\"customer_name\":\"Sam\",\"customer_address\":\"Gecko St.\",\"status\":\"unpaid\"}"
1,Product,1484731172,"{\"name\":\"Laptop\",\"price\":2100,\"stock_levels\":29}"
1,Order,1484731481,"{\"status\":\"paid\",\"ship_date\":\"2017-01-18\",\"shipping_provider\":\"DHL\"}"
2,Product,1484731671,"{\"name\":\"Microphones\",\"price\":160,\"stock_levels\":1500}"
1,Invoice,1484731920,"{\"order_id\":7,\"product_ids\":[1,5,3],\"status\":\"unpaid\",\"total\":2500}"
1,Invoice,1484732821,"{\"status\":\"paid\"}"

after the application consumes the CSV, the user should be able to query the system for the states of objects consumed at a specific point in time. Examples:

1- What's the state of Order Id=1 At timestamp=1484733173 ? {"customer_name"=>"Jack", "customer_address"=>"Trade St.", "status"=>"paid", "ship_date"=>"2017-01-18", "shipping_provider"=>"DHL"}

2- What's the state of Order Id=1 At timestamp=1484722542 ? {} # Object Didn't Exist at that time.

3- What's the state of Order Id=1 At timestamp=1484731400 ? {"customer_name"=>"Jack", "customer_address"=>"Trade St.", "status"=>"unpaid"}

The Application Should be deployed online (choose whichever provider you like, AWS, Heroku, DigitalOcean, ..etc), and the code hosted on github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment