/graph-grouping-exercise

exercise to group transaction data by truncated date for graphing

Primary LanguageGo

Exercise on grouping data for time interval graphs

This program contains function that satisfies following requirements:

  1. take in slice of Transaction structs
    type Transaction struct {
    	Value		int
    	Timestamp     time.Time
    }
        
  2. group them by truncating timestamp down to closest ‘hour’, ‘day’, ‘week’, ‘month’
  3. keeps latest transaction

To use the program

if you have go installed:

go build
./graph-grouping-exercise test-data/example-transactions-1.json hour

call the executable with path to input data json and interval

or using nix to get dependencies locked in flake.lock

nix develop
go build
./graph-grouping-exercise test-data/example-transactions-1.json hour

or using the GroupTransactions function directly from code

by passing in your data structures