-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswot_analysis.py
31 lines (25 loc) · 1010 Bytes
/
swot_analysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from datetime import datetime
from bson import ObjectId
class SWOTAnalysis:
def __init__(self, db):
self.collection = db.swot_entries
def create_analysis(self, strengths, weaknesses, opportunities, threats):
entry = {
"strengths": strengths,
"weaknesses": weaknesses,
"opportunities": opportunities,
"threats": threats,
"created_at": datetime.utcnow(),
"updated_at": datetime.utcnow()
}
return self.collection.insert_one(entry).inserted_id
def get_analysis(self, analysis_id):
return self.collection.find_one({"_id": ObjectId(analysis_id)})
def update_analysis(self, analysis_id, data):
data["updated_at"] = datetime.utcnow()
return self.collection.update_one(
{"_id": ObjectId(analysis_id)},
{"$set": data}
)
def delete_analysis(self, analysis_id):
return self.collection.delete_one({"_id": ObjectId(analysis_id)})