Code comments Removed Update
This commit is contained in:
+10
-10
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import base64
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
@@ -28,16 +28,16 @@ HEADERS = {
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
|
||||
"x-cosmos-session-281286": "0:-1#10931",
|
||||
"x-cosmos-session-295334": "0:-1#745295",
|
||||
"x-cosmos-session-317755": "0:-1#190559",
|
||||
"x-cosmos-session-382299": "0:-1#264026",
|
||||
"x-cosmos-session-418988": "0:-1#4052014",
|
||||
"x-cosmos-session-793952": "0:-1#13832",
|
||||
"x-cosmos-session-281286": "0:-1
|
||||
"x-cosmos-session-295334": "0:-1
|
||||
"x-cosmos-session-317755": "0:-1
|
||||
"x-cosmos-session-382299": "0:-1
|
||||
"x-cosmos-session-418988": "0:-1
|
||||
"x-cosmos-session-793952": "0:-1
|
||||
"x-timezone": "America/New_York",
|
||||
}
|
||||
|
||||
# The parent segment ID to chain from — update this to your latest segment
|
||||
|
||||
INITIAL_PARENT_SEGMENT_ID = "d7765a66-a24b-4620-b003-11b4c1ed2c36"
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def send_message(message: str, conversation_id: str = CONVERSATION_ID, parent_se
|
||||
|
||||
payload = json.dumps(body).encode("utf-8")
|
||||
|
||||
# Generate fresh per-request headers
|
||||
|
||||
sentry_trace_id = uuid.uuid4().hex
|
||||
sentry_span_id = uuid.uuid4().hex[:16]
|
||||
headers = dict(HEADERS)
|
||||
@@ -105,7 +105,7 @@ def send_message(message: str, conversation_id: str = CONVERSATION_ID, parent_se
|
||||
print(f"\n[IDs: {decoded}]", file=sys.stderr)
|
||||
try:
|
||||
ids = json.loads(decoded)
|
||||
# Try common key names for the segment ID
|
||||
|
||||
new_segment_id = (
|
||||
ids.get("segmentId")
|
||||
or ids.get("id")
|
||||
|
||||
@@ -2,7 +2,7 @@ import random
|
||||
from datetime import datetime, timedelta
|
||||
from pymongo import MongoClient
|
||||
|
||||
# MongoDB Setup
|
||||
|
||||
MONGO_URI = "mongodb+srv://SarayuJ:[email protected]/testing"
|
||||
client = MongoClient(MONGO_URI)
|
||||
db = client.study_buddy_db
|
||||
@@ -25,65 +25,65 @@ def get_db_for_time_and_location(hour, loc_id):
|
||||
Generate a dB level based on the hour of the day and the location.
|
||||
This creates a recognizable pattern for AI analysis.
|
||||
"""
|
||||
base_db = 40.0 # Ambient noise
|
||||
|
||||
base_db = 40.0
|
||||
|
||||
if loc_id in ['mckeldin', 'esj']:
|
||||
# Busy during the day (10am - 4pm)
|
||||
|
||||
if 10 <= hour <= 16:
|
||||
base_db = 75.0
|
||||
elif 17 <= hour <= 22:
|
||||
base_db = 60.0
|
||||
else:
|
||||
base_db = 45.0
|
||||
|
||||
|
||||
elif loc_id in ['stem', 'iribe']:
|
||||
# Busy in the afternoon/evening (2pm - 8pm)
|
||||
|
||||
if 14 <= hour <= 20:
|
||||
base_db = 70.0
|
||||
elif 9 <= hour <= 13:
|
||||
base_db = 55.0
|
||||
else:
|
||||
base_db = 42.0
|
||||
|
||||
|
||||
elif loc_id == 'stamp':
|
||||
# Busy during lunch (12pm - 2pm) and dinner (5pm - 7pm)
|
||||
|
||||
if 12 <= hour <= 14 or 17 <= hour <= 19:
|
||||
base_db = 85.0
|
||||
elif 10 <= hour <= 21:
|
||||
base_db = 65.0
|
||||
else:
|
||||
base_db = 50.0
|
||||
|
||||
|
||||
else:
|
||||
# General locations (Clarice, Yahentamitsi, Reckord, Hornbake)
|
||||
# Moderate noise during the day
|
||||
|
||||
|
||||
if 9 <= hour <= 18:
|
||||
base_db = 60.0
|
||||
else:
|
||||
base_db = 45.0
|
||||
|
||||
# Add random noise to make it look realistic (+/- 5 dB)
|
||||
|
||||
|
||||
noise = random.uniform(-5.0, 5.0)
|
||||
return max(30.0, min(100.0, base_db + noise))
|
||||
|
||||
def generate_fake_data():
|
||||
print("Clearing existing study room data...")
|
||||
collection.delete_many({})
|
||||
|
||||
|
||||
now = datetime.utcnow()
|
||||
start_time = now - timedelta(hours=24)
|
||||
|
||||
|
||||
docs_to_insert = []
|
||||
|
||||
|
||||
print("Generating 24 hours of fake data with patterns...")
|
||||
# Generate data points every 15 minutes for the last 24 hours
|
||||
|
||||
current_time = start_time
|
||||
while current_time <= now:
|
||||
hour = current_time.hour
|
||||
|
||||
|
||||
for loc in UMD_LOCATIONS:
|
||||
db_level = get_db_for_time_and_location(hour, loc["id"])
|
||||
|
||||
|
||||
doc = {
|
||||
"room_id": loc["id"],
|
||||
"location": {
|
||||
@@ -94,9 +94,9 @@ def generate_fake_data():
|
||||
"date": current_time
|
||||
}
|
||||
docs_to_insert.append(doc)
|
||||
|
||||
|
||||
current_time += timedelta(minutes=15)
|
||||
|
||||
|
||||
print(f"Inserting {len(docs_to_insert)} records into MongoDB...")
|
||||
collection.insert_many(docs_to_insert)
|
||||
print("Done!")
|
||||
|
||||
Reference in New Issue
Block a user