Task: Trending Products

Tags

General Problem Solving, Scripts, Big Data

Description

Your friend Bob is importing goods from other countries in the globe, and he want to figure out what goods is best selling and trending in the US these days.

He's not in tech, but he does get access to a pretty big database of some E-commerce website in the US.

Help him!

Specification

Write a script, that

  • Read file(s) of products statistics for the past few days, in the format of JSON lines
  • Find out top N best sellers by total sales volume
  • Also find out the top N trending products, defined by average daily sales volume increases

You can assume the data provided, is a legit database dump within a period of time, but pay attention to the following:

  • New item might appear later, calculate total sales as usual, and average daily sales increase start counting on the day it appears
  • Assume items never disappear in later days
  • If the average sales increase is less or equal to 0, ignore that item in the ranking

Configuration

Possible configuration sources are: cli

./your-prog -N 10 data1.jl data2.jl data3.jl

Example

$ cat data.jl
{"id": "1", "name": "Macbook", "date": "2019-08-11", "sales": 6000}
{"id": "2", "name": "iPad", "date": "2019-08-11", "sales": 300}
{"id": "1", "name": "Macbook", "date": "2019-08-12", "sales": 3000}
{"id": "2", "name": "iPad", "date": "2019-08-12", "sales": 2500}

$ ./your-prog -N 10 data.jl
{
  "bestSellers": [
    {"id": "1", "totalSales": 9000},
    {"id": "2", "totalSales": 2800}
  ],
  "trending": [
    {"id": "2", "averageIncrease": 2200}
  ]
}
Instructions
Get started
My Submissions

Submit to see your result!

Leaderboard

Nobody here yet, solve it now to get on the board!