Skip to content

Commit

Permalink
Merge pull request #603 from hackforla/594-BACK-LastPulledDate
Browse files Browse the repository at this point in the history
metadata table with last_pulled populated during ingest
  • Loading branch information
sellnat77 authored May 12, 2020
2 parents d89c848 + c3041b5 commit 19e3109
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions server/src/services/dataService.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import pandas as pd
from .databaseOrm import Ingest
from utils.database import db
Expand All @@ -8,8 +7,8 @@ class DataService(object):
default_table = Ingest.__tablename__

async def lastPulled(self):
# Will represent last time the ingest pipeline ran
return datetime.datetime.utcnow()
rows = db.exec_sql('SELECT last_pulled FROM metadata')
return rows.first()[0]

def standardFilters(self,
startDate=None,
Expand Down
6 changes: 5 additions & 1 deletion server/src/services/sqlIngest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def __del__(self):
def resetDatabase(self):
log('\nResetting database.')
db.exec_sql(f"""
DROP TABLE IF EXISTS {Ingest.__tablename__} CASCADE
DROP TABLE IF EXISTS {Ingest.__tablename__} CASCADE;
DROP TABLE IF EXISTS metadata;
CREATE TABLE metadata AS
SELECT * FROM (VALUES (NOW())) as vals(last_pulled);
""")
Base.metadata.create_all(db.engine)

Expand Down

0 comments on commit 19e3109

Please sign in to comment.