Add updated models
@@ -7,38 +7,37 @@ from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
-class SearchEvent(Base):
+class EventMixin(object):
+ id = Column(Integer, primary_key=True)
+ timestamp = Column(DateTime, server_default=func.now(), index=True)
+
+
+class SearchEvent(Base, EventMixin):
"""
Store searches linked to a session UUID.
"""
__tablename__ = "search_event"
- id = Column(Integer, primary_key=True)
- date = Column(DateTime, server_default=func.now(), index=True)
query = Column(String, index=True)
session_uuid = Column(UUID, index=True)
-class SearchRatingEvent(Base):
+class SearchRatingEvent(Base, EventMixin):
"""
Users can provide feedback about the quality of search results.
"""
__tablename__= "search_rating_event"
- id = Column(Integer, primary_key=True)
- date = Column(DateTime, server_default=func.now(), index=True)
query = Column(String, index=True)
rating = Column(Integer)
-class ResultClickedEvent(Base):
+class ResultClickedEvent(Base, EventMixin):
"""
Link result clicks to search sessions.
"""
__tablename__ = "result_clicked_event"
- id = Column(Integer, primary_key=True)
- date = Column(DateTime, server_default=func.now(), index=True)
session_uuid = Column(UUID, index=True)
result_uuid = Column(UUID, index=True)
query = Column(String, index=True)
@@ -53,7 +52,7 @@ class DetailPageEvents(enum.Enum):
SHARED_SOCIAL = enum.auto()
-class DetailPageEvent(Base):
+class DetailPageEvent(Base, EventMixin):
"""
Events that happen on result pages, such as clicking an attribution button
or sharing the result on social media.
@@ -61,7 +60,5 @@ class DetailPageEvent(Base):
"""
__tablename__ = "detail_page_event"
- id = Column(Integer, primary_key=True)
- date = Column(DateTime, server_default=func.now(), index=True)
result_uuid = Column(UUID, index=True)
event_type = Column(Enum(DetailPageEvents), index=True)
