mirror of
https://github.com/sstent/GarminSync.git
synced 2026-03-03 03:25:26 +00:00
checkpoint 1
This commit is contained in:
BIN
garminsync/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
garminsync/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
garminsync/__pycache__/cli.cpython-310.pyc
Normal file
BIN
garminsync/__pycache__/cli.cpython-310.pyc
Normal file
Binary file not shown.
BIN
garminsync/__pycache__/config.cpython-310.pyc
Normal file
BIN
garminsync/__pycache__/config.cpython-310.pyc
Normal file
Binary file not shown.
BIN
garminsync/__pycache__/daemon.cpython-310.pyc
Normal file
BIN
garminsync/__pycache__/daemon.cpython-310.pyc
Normal file
Binary file not shown.
BIN
garminsync/__pycache__/database.cpython-310.pyc
Normal file
BIN
garminsync/__pycache__/database.cpython-310.pyc
Normal file
Binary file not shown.
BIN
garminsync/__pycache__/garmin.cpython-310.pyc
Normal file
BIN
garminsync/__pycache__/garmin.cpython-310.pyc
Normal file
Binary file not shown.
@@ -21,6 +21,7 @@ class Activity(Base):
|
||||
duration = Column(Integer, nullable=True)
|
||||
distance = Column(Float, nullable=True)
|
||||
max_heart_rate = Column(Integer, nullable=True)
|
||||
avg_heart_rate = Column(Integer, nullable=True)
|
||||
avg_power = Column(Float, nullable=True)
|
||||
calories = Column(Integer, nullable=True)
|
||||
filename = Column(String, unique=True, nullable=True)
|
||||
@@ -63,6 +64,7 @@ class Activity(Base):
|
||||
"start_time": self.start_time,
|
||||
"activity_type": self.activity_type,
|
||||
"max_heart_rate": self.max_heart_rate,
|
||||
"avg_heart_rate": self.avg_heart_rate,
|
||||
"avg_power": self.avg_power,
|
||||
"calories": self.calories,
|
||||
}
|
||||
@@ -141,6 +143,8 @@ def sync_database(garmin_client):
|
||||
# Safely access dictionary keys
|
||||
activity_id = activity.get("activityId")
|
||||
start_time = activity.get("startTimeLocal")
|
||||
avg_heart_rate = activity.get("averageHR", None)
|
||||
calories = activity.get("calories", None)
|
||||
|
||||
if not activity_id or not start_time:
|
||||
print(f"Missing required fields in activity: {activity}")
|
||||
@@ -153,6 +157,8 @@ def sync_database(garmin_client):
|
||||
new_activity = Activity(
|
||||
activity_id=activity_id,
|
||||
start_time=start_time,
|
||||
avg_heart_rate=avg_heart_rate,
|
||||
calories=calories,
|
||||
downloaded=False,
|
||||
created_at=datetime.now().isoformat(),
|
||||
last_sync=datetime.now().isoformat(),
|
||||
|
||||
@@ -304,6 +304,7 @@ async def get_activities(
|
||||
"duration": activity.duration,
|
||||
"distance": activity.distance,
|
||||
"max_heart_rate": activity.max_heart_rate,
|
||||
"avg_heart_rate": activity.avg_heart_rate,
|
||||
"avg_power": activity.avg_power,
|
||||
"calories": activity.calories,
|
||||
"filename": activity.filename,
|
||||
|
||||
@@ -65,8 +65,10 @@ class ActivitiesPage {
|
||||
<td>${activity.activity_type || '-'}</td>
|
||||
<td>${Utils.formatDuration(activity.duration)}</td>
|
||||
<td>${Utils.formatDistance(activity.distance)}</td>
|
||||
<td>${activity.max_heart_rate || '-'}</td>
|
||||
<td>${Utils.formatHeartRate(activity.max_heart_rate)}</td>
|
||||
<td>${Utils.formatHeartRate(activity.avg_heart_rate)}</td>
|
||||
<td>${Utils.formatPower(activity.avg_power)}</td>
|
||||
<td>${activity.calories ? activity.calories.toLocaleString() : '-'}</td>
|
||||
`;
|
||||
|
||||
return row;
|
||||
|
||||
@@ -7,12 +7,13 @@ class Utils {
|
||||
return new Date(dateStr).toLocaleDateString();
|
||||
}
|
||||
|
||||
// Format duration from seconds to HH:MM
|
||||
// Format duration from seconds to HH:MM:SS
|
||||
static formatDuration(seconds) {
|
||||
if (!seconds) return '-';
|
||||
const hours = Math.floor(seconds / 3600);
|
||||
const minutes = Math.floor((seconds % 3600) / 60);
|
||||
return `${hours}:${minutes.toString().padStart(2, '0')}`;
|
||||
const secondsLeft = seconds % 60;
|
||||
return `${hours}:${minutes.toString().padStart(2, '0')}:${secondsLeft.toString().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
// Format distance from meters to kilometers
|
||||
@@ -26,6 +27,11 @@ class Utils {
|
||||
return watts ? `${Math.round(watts)}W` : '-';
|
||||
}
|
||||
|
||||
// Format heart rate (adds 'bpm')
|
||||
static formatHeartRate(hr) {
|
||||
return hr ? `${hr} bpm` : '-';
|
||||
}
|
||||
|
||||
// Show error message
|
||||
static showError(message) {
|
||||
console.error(message);
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
<th>Duration</th>
|
||||
<th>Distance</th>
|
||||
<th>Max HR</th>
|
||||
<th>Avg HR</th>
|
||||
<th>Power</th>
|
||||
<th>Calories</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="activities-tbody">
|
||||
|
||||
Reference in New Issue
Block a user