From e881e758235cbda6c9d17f194f5a9542509d2e8c Mon Sep 17 00:00:00 2001 From: enne2 Date: Wed, 20 Sep 2023 00:57:44 +0200 Subject: [PATCH] 1.1.2 --- pages/user.py | 2 +- tinymongoz.py | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pages/user.py b/pages/user.py index 66d381a..8e23cf2 100644 --- a/pages/user.py +++ b/pages/user.py @@ -23,7 +23,7 @@ def main(userid, db): {"$push": {"pagamenti": month.strftime('%Y-%m-%d %H:%M:%S')}} ) else: - collection.find_one_and_update( + collection.update_one( {"_id": ObjectId(userid)}, {"$pull": {"pagamenti": month.strftime('%Y-%m-%d %H:%M:%S')}} ) diff --git a/tinymongoz.py b/tinymongoz.py index deaff35..0440e79 100644 --- a/tinymongoz.py +++ b/tinymongoz.py @@ -15,34 +15,34 @@ collection = db.livelli # for row in jsonfile: # print(row) -collection.insert_one({"id":"3","nome":"Advanced"}) -collection.insert_one({"id":"2","nome":"Improver"}) -collection.insert_one({"id":"1","nome":"Beginners"}) +# collection.insert_one({"id":"3","nome":"Advanced"}) +# collection.insert_one({"id":"2","nome":"Improver"}) +# collection.insert_one({"id":"1","nome":"Beginners"}) -# collection = db.lezioni +collection = db.lezioni -# # collection.insert_one({'}) +# collection.insert_one({'}) -# # Start from a known Monday. -# start_date = datetime(2023,10,1) +# Start from a known Monday. +start_date = datetime(2023,10,1) -# while start_date.weekday() != 0: # 0 represents Monday in weekday() -# start_date -= timedelta(days=1) +while start_date.weekday() != 0: # 0 represents Monday in weekday() + start_date -= timedelta(days=1) -# for i in range(36): # We need 10 weeks to get 20 days (2 days per week) -# monday = start_date + timedelta(weeks=i) -# wednesday1 = monday + timedelta(days=2) # Wednesday is two days after Monday -# monday = monday.replace(hour=19, minute=30) -# wednesday1= wednesday1.replace(hour=19, minute=30) -# wednesday2 = wednesday1 -# wednesday2 = wednesday2.replace(hour=20, minute=30) +for i in range(36): # We need 10 weeks to get 20 days (2 days per week) + monday = start_date + timedelta(weeks=i) + wednesday1 = monday + timedelta(days=2) # Wednesday is two days after Monday + monday = monday.replace(hour=19, minute=30) + wednesday1= wednesday1.replace(hour=19, minute=30) + wednesday2 = wednesday1 + wednesday2 = wednesday2.replace(hour=20, minute=30) -# collection.insert_one({"sede": 1, "livello":0, "data":monday.strftime('%Y-%m-%d %H:%M:%S')}) -# collection.insert_one({"sede": 0, "livello":0, "data":wednesday1.strftime('%Y-%m-%d %H:%M:%S')}) -# collection.insert_one({"sede": 0, "livello":1, "data":wednesday2.strftime('%Y-%m-%d %H:%M:%S')}) + collection.insert_one({"sede": 1, "livello":1, "data":monday.strftime('%Y-%m-%d %H:%M:%S')}) + collection.insert_one({"sede": 0, "livello":1, "data":wednesday1.strftime('%Y-%m-%d %H:%M:%S')}) + collection.insert_one({"sede": 0, "livello":2, "data":wednesday2.strftime('%Y-%m-%d %H:%M:%S')})