aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-08 15:01:30 -0600
committerParker <contact@pkrm.dev>2024-11-08 15:01:30 -0600
commitf1411191b001bd35af83dda869ce492ff8f88899 (patch)
tree67e95f61380ef5c4f07c24d11c37a75b32c05c9f
parentf66ee5cd7dc31ac936d7b0a7aa45c92857612022 (diff)
Remove default statement for DB
-rw-r--r--app/routes/links_routes.py2
-rw-r--r--app/util/log.py1
-rw-r--r--models.py7
3 files changed, 5 insertions, 5 deletions
diff --git a/app/routes/links_routes.py b/app/routes/links_routes.py
index 1599c82..f56ebfc 100644
--- a/app/routes/links_routes.py
+++ b/app/routes/links_routes.py
@@ -51,6 +51,8 @@ async def create_link(
link=link_path,
owner=current_user.id,
redirect_link=url.url,
+ expire_date=datetime.datetime.utcnow()
+ + datetime.timedelta(days=30),
)
db.add(new_link)
db.commit()
diff --git a/app/util/log.py b/app/util/log.py
index 1d21445..58a56f9 100644
--- a/app/util/log.py
+++ b/app/util/log.py
@@ -68,6 +68,7 @@ def log(link, ip, user_agent):
new_log = Log(
owner=owner,
link=link,
+ timestamp=datetime.datetime.utcnow(),
ip=ip,
location=location,
browser=browser,
diff --git a/models.py b/models.py
index 27f1436..17f0936 100644
--- a/models.py
+++ b/models.py
@@ -24,10 +24,7 @@ class Link(Base):
link = Column(String, primary_key=True)
owner = Column(Integer, ForeignKey("users.id"), nullable=False)
redirect_link = Column(String, nullable=False)
- expire_date = Column(
- DateTime,
- default=datetime.datetime.utcnow() + datetime.timedelta(days=30),
- )
+ expire_date = Column(DateTime, nullable=False)
class Log(Base):
@@ -35,7 +32,7 @@ class Log(Base):
id = Column(Integer, primary_key=True)
owner = Column(Integer, ForeignKey("users.id"), nullable=False)
link = Column(String, ForeignKey("links.link"), nullable=False)
- timestamp = Column(DateTime, default=datetime.datetime.utcnow())
+ timestamp = Column(DateTime, nullable=False)
ip = Column(String, nullable=False)
location = Column(String, nullable=False)
browser = Column(String, nullable=False)