GPS background recording: - Batched writes (10s flush) in native service - Polling lock prevents parallel processing - Track by timestamp instead of line count - Recovery idempotent via max DB timestamp - Seq numbers on live recorded points GPX export: - Button in session detail - SAF file picker on Android (ACTION_CREATE_DOCUMENT) - GPS config in metadata (accuracy, minSpeed, minDist) Charts: - Pinch zoom enabled at creation (Hammer.js registers handlers) - touch-action: pan-y blocks pinch in normal view (page scrolls) - Fullscreen: CSS-only expand (no canvas manipulation) - Downsampled to 500 points for smooth rendering - Back gesture collapses fullscreen before closing modal Build: --real flag finds first non-emulator device
35 lines
1.9 KiB
JavaScript
35 lines
1.9 KiB
JavaScript
// Activity calorie expenditure rates
|
||
// kcal_per_min_per_kg: calories burned per minute per kg of body weight
|
||
// (beyond basal metabolic rate)
|
||
// default_min: typical duration in minutes
|
||
|
||
export const ACTIVITIES = [
|
||
{ key: "walk", name: "прогулка", aliases: ["прогулк", "ходьб", "гулял", "пешком"], kcal_min_kg: 0.05, default_min: 30 },
|
||
{ key: "bike", name: "велосипед", aliases: ["велосипед", "вело", "велик"], kcal_min_kg: 0.08, default_min: 60 },
|
||
{ key: "run", name: "бег", aliases: ["бег", "пробежк", "бежал"], kcal_min_kg: 0.12, default_min: 30 },
|
||
{ key: "sleep", name: "сон", aliases: ["сон", "спал", "сплю"], kcal_min_kg: 0.015, default_min: 480 },
|
||
{ key: "chore", name: "домашние дела", aliases: ["убор", "уборк", "стирк", "готовк", "мыл"], kcal_min_kg: 0.04, default_min: 30 },
|
||
{ key: "desk_work", name: "работа за столом", aliases: ["работ", "сидел"], kcal_min_kg: 0.02, default_min: 60 },
|
||
{ key: "stairs", name: "лестница", aliases: ["лестниц", "ступен"], kcal_min_kg: 0.10, default_min: 5 },
|
||
];
|
||
|
||
export const ACTIVITY_MAP = Object.fromEntries(
|
||
ACTIVITIES.map((a) => [a.key, a])
|
||
);
|
||
|
||
export function matchActivity(text) {
|
||
const lower = text.toLowerCase();
|
||
for (const act of ACTIVITIES) {
|
||
for (const alias of act.aliases) {
|
||
if (lower.includes(alias.toLowerCase())) {
|
||
return act;
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
// Calculate kcal for an activity given weight and duration
|
||
export function activityKcal(activity, weightKg, minutes) {
|
||
return Math.round(activity.kcal_min_kg * weightKg * minutes);
|
||
}
|