-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.py
51 lines (38 loc) · 1.2 KB
/
commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import logging
from datetime import date
from flask import Blueprint
logger = logging.getLogger(__name__)
cmd = Blueprint('cmd', __name__)
@cmd.cli.command("list_segments")
def list_Segments():
logger.info('List segments')
from actions import list_segments
list_segments()
@cmd.cli.command("load_segments")
def load_segments():
logger.info('Load segments')
from actions import load_segments
load_segments()
@cmd.cli.command("collect_today")
def collect_day():
logger.info('Collecting day counts')
from actions import store_segments_counts
store_segments_counts()
@cmd.cli.command("count_today")
def count_today():
from models import SegmentEffort
today = date.today()
count = SegmentEffort.query.filter_by(date=today).count()
logger.info(f'{count} efforts collected for today')
@cmd.cli.command("latest_entry")
def latest_entry():
from actions import latest_entry
latest_entry()
@cmd.cli.command("delete_today")
def delete_today():
from models import SegmentEffort
from app import db
today = date.today()
count = SegmentEffort.query.filter_by(date=today).delete()
db.session.commit()
logger.info(f'{count} efforts deleted for today')