added segments
This commit is contained in:
38
FitnessSync/scratch/inspect_segment.py
Normal file
38
FitnessSync/scratch/inspect_segment.py
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
# Add backend to path
|
||||
sys.path.append(os.path.join(os.getcwd(), 'backend'))
|
||||
|
||||
from src.models.segment import Segment
|
||||
from src.utils.config import config
|
||||
|
||||
# Setup DB
|
||||
engine = create_engine(config.DATABASE_URL)
|
||||
Session = sessionmaker(bind=engine)
|
||||
db = Session()
|
||||
|
||||
def inspect_segment(segment_name):
|
||||
print(f"--- Inspecting Segment: {segment_name} ---")
|
||||
|
||||
segment = db.query(Segment).filter(Segment.name == segment_name).first()
|
||||
if not segment:
|
||||
print("Segment not found")
|
||||
return
|
||||
|
||||
print(f"ID: {segment.id}")
|
||||
print(f"Name: {segment.name}")
|
||||
print(f"Distance: {segment.distance} meters")
|
||||
|
||||
points = json.loads(segment.points) if isinstance(segment.points, str) else segment.points
|
||||
print(f"Point Logic: {len(points)} points")
|
||||
if len(points) > 0:
|
||||
print(f"Start: {points[0]}")
|
||||
print(f"End: {points[-1]}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
inspect_segment("TEST3")
|
||||
Reference in New Issue
Block a user