removed user_db; added make remove_db

This commit is contained in:
m 2021-02-01 12:54:02 +01:00
parent c0fa81c373
commit 20ed95115b
6 changed files with 25 additions and 3 deletions

View File

@ -69,6 +69,10 @@ db:
#if not exist generate task.sqlite3 database based on schema
sqlite3 database/$(TASK_DB).$(DB_SUFFIX) '.read database/$(TASK_DB).sql'
reset_db:
mv database/$(TASK_DB).$(DB_SUFFIX) database/$(TASK_DB).$(DB_SUFFIX).$(date -u +"%Y-%m-%d")
sqlite3 database/$(TASK_DB).$(DB_SUFFIX) '.read database/$(TASK_DB).sql'
run:
#TODO (supervisor)

View File

@ -6,6 +6,7 @@ PARSED_MESSAGEENTITIES = dict[MessageEntity, str]
#paths
CONFIG_FILE_PATH = 'app/config.json'
TASKS_DB_PATH = 'database/task.sqlite3'
USER_DB_PATH = 'database/user.sqlite3'
#runtime constants
ANY_MENTION = [MessageEntity.MENTION, MessageEntity.TEXT_MENTION]

View File

@ -9,6 +9,7 @@ from constants import PERIODS, TASKS_DB_PATH
# db connections
task_db: sqlite3.Connection = sqlite3.connect(TASKS_DB_PATH,check_same_thread=False)
#user_db: sqlite3.Connection = sqlite3.connect(USER_DB_PATH,check_same_thread=False)
### TASK related queries
@ -214,4 +215,5 @@ def get_top_contributors( top_n: int, period: Literal['day','week','month','ye
;"""
query_results = db.execute(query, (top_n,))
return dict(query_results)
return dict(query_results)

View File

@ -134,16 +134,17 @@ def export_db(update: Update, context: CallbackContext) -> None:
update.message.reply_document(document=file_to_send, filename=file_name, quote=True)
@command
def stats(update: Update, context: CallbackContext) -> None:
"""stats about task done in a specific timeframe
/stats topN [bountyhunters]
[[day | today] | yesterday | Ndays | daysN |
/stats topN [[day | today] | yesterday | Ndays | daysN |
[week | thisweek] | pastweek | Nweeks | weeksN |
[month | thismonth] | pastmonth | Nmonths | monthsN |
[year | thisyear] | pastyear |
[overall | alltimes]]
[bountyhunters]
topN: get only the N top contributors
day: """ #TODO user guide

Binary file not shown.

14
database/user.sql Normal file
View File

@ -0,0 +1,14 @@
-- db with informations about the telegram user
PRAGMA foreign_keys = ON;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS users (
username TEXT,
firstname TEXT,
lastname TEXT,
object BLOB
);
COMMIT;