]> rtime.felk.cvut.cz Git - hubacji1/coffee-getter.git/blob - README.md
Add top 5 mate drinkers runnable
[hubacji1/coffee-getter.git] / README.md
1 # Coffeebot getter
2 Somehow friendly API to get and share coffee related data from database.
3
4 # Development
5 ## Runnables
6 Scripts to be run by systemd timers should by as simple as possible, runnable,
7 python3 script file.
8
9 There are no tests needed for runnables.
10
11 ## Timers
12 For running tasks periodically, please see [Timers][6] and [User][7] pages
13 about systemd on archlinux wiki.
14
15 The example `top5_mate_stats.service`:
16 ```
17 [Unit]
18 Description=Run top 5 Mate drinkers stats
19
20 [Service]
21 Environment=PYTHONPATH=/path/to/coffee-getter/repo/
22 ExecStart=/path/to/coffee-getter/repo/run/top5_mate_stats.py
23 ```
24
25 The example `top5_mate_stats.timer`:
26 ```
27 [Unit]
28 Description=Run top 5 Mate drinkers stats each Mon 9am
29
30 [Timer]
31 OnCalendar=Mon *-*-* 09:00:00
32 Persistent=true
33
34 [Install]
35 WantedBy=timers.target
36 ```
37
38 Both files must be stored in `~/.config/systemd/user/` directory.
39
40 Then enable timer and service by:
41 ```
42 systemctl --user enable top5_mate_stats.timer
43 systemctl --user enable top5_mate_stats.service
44 ```
45
46 And start timer by:
47 ```
48 systemctl --user start top5_mate_stats.timer
49 ```
50
51 # Contribute
52 ## Code
53 For quick orientation see the [changelog][1].
54
55 Please, think about [The seven rules of a great Git commit message][2] when
56 making commit. The project use [OneFlow][3] branching model with the `master`
57 branch as the branch where the development happens.
58
59 ## TDD
60 Test Driven Development (TDD) is used in this project. Each *feature* **must**
61 start with adding test and all the tests **must** pass before merge to the
62 *master*.
63
64 Run the tests by:
65 ```
66 python3 -m unittest discover ut/
67 ```
68
69 See [unittest][5] for start.
70
71 ## Database
72 By default, sqlite3 `coffee.db` file is needed. You may create testing copy of
73 database by:
74 ```
75 python3 -c '
76 from ut.test_db import create_test_db
77 create_test_db("coffee.db")
78 '
79 ```
80
81 Database is needed to pass the tests.
82
83 ## License
84 This project is developed under [GNU GPLv3 license][4].
85
86 [1]: ./CHANGELOG.md
87 [2]: https://chris.beams.io/posts/git-commit/
88 [3]: http://endoflineblog.com/oneflow-a-git-branching-model-and-workflow
89 [4]: ./LICENSE
90 [5]: https://docs.python.org/3.5/library/unittest.html
91 [6]: https://wiki.archlinux.org/index.php/Systemd/Timers
92 [7]: https://wiki.archlinux.org/index.php/Systemd/User