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