Skip to content

Commit

Permalink
Fix error when inserting without an expiry (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Buried-In-Code authored Sep 13, 2021
1 parent 9121a50 commit 8d92274
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v2.25.0
rev: v2.26.0
hooks:
- id: pyupgrade
5 changes: 4 additions & 1 deletion Simyan/sqlite_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def get(self, key: str) -> Optional[Dict[str, Any]]:
return self.select(query=key) or None

def insert(self, query: str, response: str):
expiry = datetime.now() + timedelta(days=self.expiry)
if self.expiry:
expiry = datetime.now() + timedelta(days=self.expiry)
else:
expiry = datetime.now()
self.cur.execute(
"INSERT INTO queries(query, response, expiry) VALUES(?, ?, ?);",
(query, json.dumps(response), expiry.strftime("%Y-%m-%d")),
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Simyan"
version = "0.5.0"
version = "0.5.1"
description = "A Python wrapper for the Comicvine API."
license = "GPL-3.0-or-later"
authors = ["Buried-In-Code <6057651+Buried-In-Code@users.noreply.github.com>"]
Expand Down
Binary file modified tests/Simyan-Cache.sqlite
Binary file not shown.

0 comments on commit 8d92274

Please sign in to comment.