This app is a simple but extendable cli application to find most active cookie in a given log file.
Our goal is to write an application which finds the most active cookie in the given log file. Currently, we only support the csv files with the following structure.
Input: test.csv
cookie,timestamp
fbcn5UAVanZf6UtG,2018-12-08T09:30:00+00:00
4sMM2LxV07bPJzwf,2018-12-07T23:30:00+00:00
To run this app, you will need to have the following installed on your system:
- sbt 1.4
- Scala 2.13
- Scala-Native 0.4.9
Please visit official scala download page and follow the related steps.
Please visit official scala-native download page and follow the related steps.
To get started with this app, clone the repository to your local machine:
git clone https://github.com/dagdelenmustafa/active-cookie.git
cd active-cookie
Then build the project using sbt
and create executable file with nativeLink
command.
sbt nativeLink
This command will create the executable file under the target
folder but this repository's root folder contains a symlink
which name is run
to the file and you can use it easily.
active-cookie
app takes two parameter. One for the cookie log file path and one for the date that we want to find the most active cookie.
Here is the --help
output of the app.
./run --help
Usage: active-cookie --file <string> --date <string>
Find most active cookie at given time!
Options and flags:
--help
Display this help text.
--file <string>, -f <string>
Cookie log file path.
--date <string>, -d <string>
The date the most active cookie will be found.
Example usage with the test csv:
./run --file src/test/resources/test.csv --date 2018-12-08
AtY0laUfhglK3lC7
5UAVanZf6UtGyKVS
Test files are located under test
folder. To run the tests, simple run the following command:
sbt test
We use following dependencies to build the application.
- cats: It offers functional data structures and syntax.
- decline: It enables us to handle command-line arguments in a functional way.
- oslib: simple i/o utilities.
active-cookie
is an extendable cli application and users can easily extend support for new files at any time. To make this
program more generic, we introduce the CookieLog
trait and users can create a new active cookie extractor by extending this trait.
trait CookieLog {
def getMostActiveForDate(date: String): Either[Throwable, List[CookieOccurence]]
protected def convert(lines: List[String]): Either[Throwable, List[CookieRow]]
}
In this trait we have two different method. convert
method gets a list of strings which is the representation of the log file rows.
Then it converts this rows into a structured form. We want to make this method extendable because each file has different type of structure.
And other method is getMostActiveForDate
. This is the place that users can implement their activeness business logic.
Users can determine different kinds of activeness logic for different type of files.
This project is licensed under the Apache-2.0.