James McCool commited on
Commit
24a1053
·
1 Parent(s): a769f8a

Refactor date handling in init_conn function of app.py. Updated date range logic to use the current date for filtering, setting min_date to one year ago and max_date to one day ago. This change enhances the accuracy and relevance of game log retrieval for analysis.

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -13,9 +13,11 @@ def init_conn():
13
  client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
14
  db = client["League_of_Legends_Database"]
15
 
 
 
16
  collection = db["gamelogs"]
17
- min_date = datetime.strptime(collection.find_one({}, sort=[("date", 1)])["date"], "%Y-%m-%d %H:%M:%S")
18
- max_date = datetime.strptime(collection.find_one({}, sort=[("date", -1)])["date"], "%Y-%m-%d %H:%M:%S")
19
  team_names = collection.distinct("teamname")
20
  player_names = collection.distinct("playername")
21
 
 
13
  client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
14
  db = client["League_of_Legends_Database"]
15
 
16
+ current_date = datetime.now()
17
+
18
  collection = db["gamelogs"]
19
+ max_date = current_date - timedelta(days=1)
20
+ min_date = current_date - timedelta(days=365)
21
  team_names = collection.distinct("teamname")
22
  player_names = collection.distinct("playername")
23