def clock_in(chat_id: Union[str, int]): chat_id = str(chat_id) _date = user_now(chat_id, True) _table.put_item( Item={ 'chat_id': chat_id, 'date': _date, 'ttl': ttl() } ) # in main, when we perform a clock in/out we check for which state # we'll end up in. # if it is a clock out, then it'll override whatever it is in the user_info field # so we can safely put "clocked_in" as the state for now set_clocked_in(chat_id) return _date
def last_month_entries(chat_id: Union[str, int]): end = _beginning(user_now(chat_id).replace(day=1)) - timedelta(microseconds=1) start = _beginning(end.replace(day=1)).isoformat() end = end.isoformat() return query_interval(chat_id, start, end)
def last_week_entries(chat_id: Union[str, int]): now = user_now(chat_id) end = _end(now - timedelta(days=(now.weekday() + 2))) start = _beginning(end - timedelta(days=6)).isoformat() end = end.isoformat() return query_interval(chat_id, start, end)
def yesterday_entries(chat_id: Union[str, int]): yesterday = user_now(chat_id) - timedelta(days=1) return that_day_entries(chat_id, yesterday.isoformat())
def today_entries(chat_id: Union[str, int]): return that_day_entries(chat_id, user_now(chat_id).isoformat())