Skip to content

Commit

Permalink
Added the timestamp field to ETLPostQueryOutcome (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwilliams committed Jul 12, 2019
1 parent 52f0bbc commit 17f908d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion flowdb/sql/04_schema_other.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ CREATE TABLE etl.post_etl_queries (
cdr_type TEXT,
type_of_query_or_check TEXT,
outcome TEXT,
optional_comment_or_description TEXT
optional_comment_or_description TEXT,
timestamp TIMESTAMP WITH TIME ZONE,
);

COMMENT ON TABLE etl.post_etl_queries
Expand Down
2 changes: 2 additions & 0 deletions flowetl/etl/etl/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class ETLPostQueryOutcome(Base):
type_of_query_or_check = Column(String)
outcome = Column(String)
optional_comment_or_description = Column(String)
timestamp = Column(DateTime(timezone=True))

def __init__(
self,
Expand All @@ -131,6 +132,7 @@ def __init__(
self.type_of_query_or_check = type_of_query_or_check
self.outcome = outcome
self.optional_comment_or_description = optional_comment_or_description
self.timestamp = pendulum.utcnow()

@classmethod
def set_outcome(
Expand Down
21 changes: 13 additions & 8 deletions flowetl/etl/tests/test_postetl_query_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ def test_can_set_outcome(session):
"optional_comment_or_description": "Optional description",
}

ETLPostQueryOutcome.set_outcome(
cdr_type=query_data["cdr_type"],
cdr_date=query_data["cdr_date"],
type_of_query_or_check=query_data["type_of_query_or_check"],
outcome=query_data["outcome"],
optional_comment_or_description=query_data["optional_comment_or_description"],
session=session,
)
now = pendulum.parse("2016-01-01")
with patch("pendulum.utcnow", lambda: now):
ETLPostQueryOutcome.set_outcome(
cdr_type=query_data["cdr_type"],
cdr_date=query_data["cdr_date"],
type_of_query_or_check=query_data["type_of_query_or_check"],
outcome=query_data["outcome"],
optional_comment_or_description=query_data[
"optional_comment_or_description"
],
session=session,
)

rows = session.query(ETLPostQueryOutcome).all()
assert len(rows) == 1
Expand All @@ -44,6 +48,7 @@ def test_can_set_outcome(session):
assert row.cdr_date == query_data["cdr_date"]
assert row.type_of_query_or_check == query_data["type_of_query_or_check"]
assert row.outcome == query_data["outcome"]
assert row.timestamp == now
assert (
row.optional_comment_or_description
== query_data["optional_comment_or_description"]
Expand Down

0 comments on commit 17f908d

Please sign in to comment.