- Clone repository
- Go into the repository and run
python3 -m venv env
(ifpython3
is not found, you might have to usepython
or verify your Python installation)
- Run
source env/bin/activate
to start the virtual environment - Run
pip install -r requirements.txt
to install the dependencies
- Run
python src/db_seed.py
This will seed the database with 5 habits and their tasks with past tasks completed.
Delete the file called database.db
.
- In one terminal window (don't forget to set up virtual env), run
python3 src/main.py
, dont close this terminal and simply leave it in the background. You can provide the argument--port
to override the port (default 5000). - In a new terminal window (don't forget to set up virtual env), run
python3 src/cli.py [command]
with the arguments required - Repeat 2 as needeed
- Once done, close the terminals
To run the tests:
- Start the backend
python3 src/main.py
- In a new terminal window, run
python -m unittest discover -s src
For formatting we use black.
Run black src
When adding dependencies, always make sure you are using the virtual environment source env/bin/activate
.
- Add dependency to
requirements.txt
- Run
pip install -r requirements.txt
to install dependency
You can use -h
to display help for the CLI.
Here are the different sub commands:
habits:create Create a new habit
habits:list List habits with filters
habits:update Update a habit
habits:delete Delete a habit
tasks:list List tasks
tasks:active List tasks that are active and can be completed
tasks:complete Complete a task
analytics Query analytics. You can already get a lot of information using the list commands, but this is a
central analytics helper.
python src/cli.py habits:create --name test --description "test description" --interval P1D --lifetime P2D --active true --start 2023-10-24T08:00:00 --end 2024-12-27T22:00:00
python src/cli.py habits:list --id *in(2,3) --name test --description test --interval P1D --lifetime P2D --active true --start <2023-10-24T08:00:00 --end >2024-12-27T22:00:00
python src/cli.py habits:update --id 1 --name test --description "test description" --interval P1D --lifetime P2D --active true --start 2023-10-24T08:00:00 --end 2024-12-27T22:00:00
python src/cli.py habits:delete --id 1
python src/cli.py tasks:list --habit_id 2 --completed true --start 2023-10-24T08:00:00 --end 2024-12-27T22:00:00
python src/cli.py tasks:active
python src/cli.py tasks:complete --id 336
In the case of analytics, there is an endpoint that will wrap around the existing commands and also provides some more.
python src/cli.py analytics list_current_habits
python src/cli.py analytics list_current_habits --interval P1D
python src/cli.py analytics list_longest_streaks
python src/cli.py analytics list_longest_streaks --habit_id 1
python src/cli.py analytics list_longest_streaks --streak >5
python src/cli.py analytics get_longest_streak
python src/cli.py analytics get_longest_streak --habit_id 1