This commit is contained in:
2022-11-19 14:35:34 +03:00
parent 57e1460356
commit 47b285f8ac
18 changed files with 162 additions and 218 deletions

View File

@@ -1,6 +1,6 @@
from datetime import datetime
from sqlalchemy import Column, DateTime, ForeignKey
from base.orm import Base
from sqlalchemy import Column, DateTime, ForeignKey, Integer
from base.orm import Base, local_session
class ViewedEntry(Base):
@@ -8,6 +8,18 @@ class ViewedEntry(Base):
viewer = Column(ForeignKey("user.slug"), default='anonymous')
shout = Column(ForeignKey("shout.slug"))
amount = Column(Integer, default=1)
createdAt = Column(
DateTime, nullable=False, default=datetime.now, comment="Created at"
)
@staticmethod
def init_table():
with local_session() as session:
entry = {
"shout": "genesis-block",
"amount": 0
}
viewed = ViewedEntry.create(**entry)
session.add(viewed)
session.commit()