Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Add error message for invalid time ranges #138

Open
TimJentzsch opened this issue Dec 25, 2021 · 0 comments
Open

Add error message for invalid time ranges #138

TimJentzsch opened this issue Dec 25, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@TimJentzsch
Copy link
Contributor

The bot currently doesn't properly validate that the given time range is correct.
It should check that the after date is smaller than the before date.
It also has to take into account the default values if none are specified.

It might also be a problem if the user asks for data that is before they started transcribing.

Stacktrace:

Dec 25 19:11:07 localhost python[967]: 2021-12-25 19:11:07,972 | WARNING | [d650b09d-af74-473f-9d00-3e4efd63e75d] KeyError: 'date'
Dec 25 19:11:07 localhost python[967]: Traceback (most recent call last):
Dec 25 19:11:07 localhost python[967]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3361, in get_loc
Dec 25 19:11:07 localhost python[967]:     return self._engine.get_loc(casted_key)
Dec 25 19:11:07 localhost python[967]:   File "pandas/_libs/index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc
Dec 25 19:11:07 localhost python[967]:   File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc
Dec 25 19:11:07 localhost python[967]:   File "pandas/_libs/hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
Dec 25 19:11:07 localhost python[967]:   File "pandas/_libs/hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
Dec 25 19:11:07 localhost python[967]: KeyError: 'date'
Dec 25 19:11:07 localhost python[967]: The above exception was the direct cause of the following exception:
Dec 25 19:11:07 localhost python[967]: Traceback (most recent call last):
Dec 25 19:11:07 localhost python[967]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/discord_slash/client.py", line 872, in invoke_command
Dec 25 19:11:07 localhost python[967]:     await func.invoke(ctx, args)
Dec 25 19:11:07 localhost python[967]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/discord_slash/model.py", line 291, in invoke
Dec 25 19:11:07 localhost python[967]:     return await coro
Dec 25 19:11:07 localhost python[967]:   File "/data/buttercup/buttercup/cogs/history.py", line 525, in _history
Dec 25 19:11:07 localhost python[967]:     history_data = self.get_user_history(user, after_time, before_time)
Dec 25 19:11:07 localhost python[967]:   File "/data/buttercup/buttercup/cogs/history.py", line 434, in get_user_history
Dec 25 19:11:07 localhost python[967]:     rate_data = self.get_all_rate_data(user, time_frame, after_time, before_time)
Dec 25 19:11:07 localhost python[967]:   File "/data/buttercup/buttercup/cogs/history.py", line 375, in get_all_rate_data
Dec 25 19:11:07 localhost python[967]:     new_frame["date"] = new_frame["date"].apply(lambda x: parser.parse(x))
Dec 25 19:11:07 localhost python[967]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/pandas/core/frame.py", line 3458, in __getitem__
Dec 25 19:11:07 localhost python[967]:     indexer = self.columns.get_loc(key)
Dec 25 19:11:07 localhost python[967]:   File "/data/buttercup/.venv/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3363, in get_loc
Dec 25 19:11:07 localhost python[967]:     raise KeyError(key) from err
Dec 25 19:11:07 localhost python[967]: KeyError: 'date'
@TimJentzsch TimJentzsch added the bug Something isn't working label Dec 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant