]> rtime.felk.cvut.cz Git - hubacji1/coffee-getter.git/blobdiff - README.md
Update sort to include second field
[hubacji1/coffee-getter.git] / README.md
index 12e4c57a10111bd84e806143f3c75b66c1929252..0dd542104d1fcff55fd5dd0caeffc89d68748c2c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,6 +1,60 @@
 # Coffeebot getter
 Somehow friendly API to get and share coffee related data from database.
 
+# Development
+## Database and Getter
+`cbdb` module is used as interface to database. When getting data from
+database, add methods here.
+
+Data got from database are processed in `cbgetter` module. Feel free to add
+formatting methods here. Also communication to slack is handled in this module.
+
+## Runnables
+Scripts to be run by systemd timers should by as simple as possible, runnable,
+python3 script file.
+
+There are no tests needed for runnables.
+
+## Timers
+For running tasks periodically, please see [Timers][6] and [User][7] pages
+about systemd on archlinux wiki.
+
+The example `top5_mate_stats.service`:
+```
+[Unit]
+Description=Run top 5 Mate drinkers stats
+
+[Service]
+Environment=PYTHONPATH=/path/to/coffee-getter
+ExecStart=/path/to/coffee-getter/run/top5_mate_stats.py
+```
+
+The example `top5_mate_stats.timer`:
+```
+[Unit]
+Description=Run top 5 Mate drinkers stats each Mon 9am
+
+[Timer]
+OnCalendar=Mon *-*-* 09:00:00
+Persistent=true
+
+[Install]
+WantedBy=timers.target
+```
+
+Both files must be stored in `~/.config/systemd/user/` directory.
+
+Then enable timer and service by:
+```
+systemctl --user enable top5_mate_stats.timer
+systemctl --user enable top5_mate_stats.service
+```
+
+And start timer by:
+```
+systemctl --user start top5_mate_stats.timer
+```
+
 # Contribute
 ## Code
 For quick orientation see the [changelog][1].
@@ -22,31 +76,13 @@ python3 -m unittest discover ut/
 See [unittest][5] for start.
 
 ## Database
-By default, sqlite3 `coffee.db` file is needed. Please, see [coffee_db.sql][6]
-for the database format. You may create testing copy of database by:
-```
-wget http://rtime.felk.cvut.cz/gitweb/coffee/coffee-flask.git/blob_plain/refs/heads/master:/coffee_db.sql
-sqlite3 coffee.db < coffee_db.sql
-```
-
-Then add some testing data by:
+By default, sqlite3 `coffee.db` file is needed. You may create testing copy of
+database by:
 ```
-sqlite3 coffee.db "INSERT INTO "users" VALUES('1111','tester')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'espresso lungo')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'Club-Mate 0,5 l')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'Club-Mate 0,33 l')"
-sleep 1
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'espresso lungo')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'Club-Mate 0,5 l')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'Club-Mate 0,33 l')"
-sleep 1
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'espresso lungo')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'Club-Mate 0,5 l')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'Club-Mate 0,33 l')"
-sleep 1
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'espresso lungo')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'Club-Mate 0,5 l')"
-sqlite3 coffee.db "insert into coffees (id, flavor) values ('1111', 'Club-Mate 0,33 l')"
+python3 -c '
+from ut.test_db import create_test_db
+create_test_db("coffee.db")
+'
 ```
 
 Database is needed to pass the tests.
@@ -59,4 +95,5 @@ This project is developed under [GNU GPLv3 license][4].
 [3]: http://endoflineblog.com/oneflow-a-git-branching-model-and-workflow
 [4]: ./LICENSE
 [5]: https://docs.python.org/3.5/library/unittest.html
-[6]: http://rtime.felk.cvut.cz/gitweb/coffee/coffee-flask.git/blob/refs/heads/master:/coffee_db.sql
+[6]: https://wiki.archlinux.org/index.php/Systemd/Timers
+[7]: https://wiki.archlinux.org/index.php/Systemd/User