perf: parallelize DB queries across routes, clean up fitness UI
Parallelize sequential DB queries in 11 API routes and page loaders using Promise.all — measurements/latest, stats/overview, goal streak, exercises, sessions, task stats, monthly expenses, icon page, offline-db. Move calorie tracking out of /fitness/measure (now under /fitness/nutrition only). Remove fade-in entrance animations from nutrition page. Progressive streak computation: scan 3 months first, widen only if needed. Bump versions to 1.1.1 / 0.2.1.
This commit is contained in:
@@ -20,20 +20,12 @@ export const GET: RequestHandler = async ({ url, locals }) => {
|
||||
const startDate = new Date();
|
||||
startDate.setMonth(startDate.getMonth() - monthsBack);
|
||||
|
||||
const totalPayments = await Payment.countDocuments();
|
||||
const paymentsInRange = await Payment.countDocuments({
|
||||
date: {
|
||||
$gte: startDate,
|
||||
$lte: endDate
|
||||
}
|
||||
});
|
||||
const expensePayments = await Payment.countDocuments({
|
||||
date: {
|
||||
$gte: startDate,
|
||||
$lte: endDate
|
||||
},
|
||||
category: { $ne: 'settlement' }
|
||||
});
|
||||
const dateRange = { $gte: startDate, $lte: endDate };
|
||||
const [totalPayments, paymentsInRange, expensePayments] = await Promise.all([
|
||||
Payment.countDocuments(),
|
||||
Payment.countDocuments({ date: dateRange }),
|
||||
Payment.countDocuments({ date: dateRange, category: { $ne: 'settlement' } })
|
||||
]);
|
||||
|
||||
// Aggregate payments by month and category
|
||||
const pipeline = [
|
||||
|
||||
Reference in New Issue
Block a user