Skip to content

pbstck/homework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Homework

Aggregating data

We have one data source: a folder with json files. Each file contains a json object.

{ 
  "target_path": "/code1/code2/code3",
  "time": "2020-01-23",
  "count": 12
}
{ 
  "target_path": "/code1/code2",
  "time": "2020-01-23",
  "count": 5
}
{ 
  "target_path": "/code1/code2/code3",
  "time": "2020-01-23",
  "count": 13
}
{ 
  "target_path": "/code1",
  "time": "2020-01-23",
  "count": 15
}
{ 
  "target_path": "/code1",
  "time": "2020-01-24",
  "count": 15
}

The idea is to aggregate those data and end up with a count for each matching hierarchy level extracted from target_path.

In this example, the expected output is

[
{
  "target": "/code1",
  "time": "2020-01-23",
  "count": 45
},
{
  "target": "/code1/code2",
  "time": "2020-01-23",
  "count": 30
},
{
  "target": "/code1/code2/code3",
  "time": "2020-01-23",
  "count": 25
},
{
  "target": "/code1",
  "time": "2020-01-24",
  "count": 15
}
]

where the first element is the top level aggregation "code1" with a count of 45 (The sum of all elements having code1 as first part of their path)

Work

Your job is to implement the program that will perform the merge shown above. You can code in the language of your choice. Your program will take as a single argument the path to the folder containing the datasource.

./homework path/to/datasource

The expected output file should be name as follow: <datasource-folder-name>-agg.json, the file has to be placed at the same level as the datasource folder.

In order to test the homework, we will issue the following command:

./homework-check homework path/to/datasource

Which will execute your program with the datasource path as the first argument as stated in the first paragraph and check the output.

Also, feel free to override this README in order to provide informations and context on:

  • the language you are using
  • the development environment used
  • the framework(s) you are using
  • anything you think might be relevant for us to understand your choices.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •