Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1142,7 +1142,7 @@ def fetch_and_store_data():
|
|
| 1142 |
|
| 1143 |
|
| 1144 |
def fetch_and_store_data_market():
|
| 1145 |
-
latest_doc =
|
| 1146 |
if latest_doc and "Reported Date" in latest_doc:
|
| 1147 |
latest_date = latest_doc["Reported Date"]
|
| 1148 |
else:
|
|
@@ -1157,7 +1157,7 @@ def fetch_and_store_data_market():
|
|
| 1157 |
to_date = (datetime.now() - timedelta(days=1)).strftime('%d %b %Y')
|
| 1158 |
from_date_obj = datetime.strptime(from_date, '%d %b %Y')
|
| 1159 |
to_date_obj = datetime.strptime(to_date, '%d %b %Y')
|
| 1160 |
-
if
|
| 1161 |
print("Data already scraped")
|
| 1162 |
return None
|
| 1163 |
# Build the URL to be requested
|
|
|
|
| 1142 |
|
| 1143 |
|
| 1144 |
def fetch_and_store_data_market():
|
| 1145 |
+
latest_doc = collection.find_one(sort=[("Reported Date", -1)])
|
| 1146 |
if latest_doc and "Reported Date" in latest_doc:
|
| 1147 |
latest_date = latest_doc["Reported Date"]
|
| 1148 |
else:
|
|
|
|
| 1157 |
to_date = (datetime.now() - timedelta(days=1)).strftime('%d %b %Y')
|
| 1158 |
from_date_obj = datetime.strptime(from_date, '%d %b %Y')
|
| 1159 |
to_date_obj = datetime.strptime(to_date, '%d %b %Y')
|
| 1160 |
+
if to_date_obj < from_date_obj:
|
| 1161 |
print("Data already scraped")
|
| 1162 |
return None
|
| 1163 |
# Build the URL to be requested
|