-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV-1673: Add accessed datetime column mixin and include in cohort ta…
…ble (#67)
- Loading branch information
Showing
3 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Mixin for adding an accessed timestamp column to track the last time a record was accessed.""" | ||
import datetime | ||
|
||
from sqlalchemy import schema, sql | ||
from sqlalchemy.sql import sqltypes | ||
|
||
|
||
class AccessedColumnMixin: | ||
"""A mixin to add accessed timestamp column to a data model. | ||
Attributes: | ||
accessed_datetime: Metadata describing when a row was last accessed. | ||
""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
accessed_datetime = schema.Column( | ||
sqltypes.DateTime(timezone=True), | ||
nullable=False, | ||
server_default=sql.text("now()"), | ||
onupdate=datetime.datetime.utcnow, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters