MCPcopy Create free account
hub / github.com/devxnshsharma/UnMessify / renderQuickStats

Method renderQuickStats

app.js:1701–1732  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1699 }
1700
1701 renderQuickStats() {
1702 const avgPerMeal = document.getElementById('avgPerMeal');
1703 const mostExpensiveDay = document.getElementById('mostExpensiveDay');
1704 const cheapestDay = document.getElementById('cheapestDay');
1705
1706 // Calculate average per meal
1707 if (this.expenses.length > 0) {
1708 const avg = this.derived.totalSpent / this.expenses.length;
1709 avgPerMeal.textContent = formatCurrency(avg);
1710 } else {
1711 avgPerMeal.textContent = '₹0';
1712 }
1713
1714 // Calculate most/cheapest days
1715 const dayTotals = {};
1716 const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
1717
1718 this.expenses.forEach(exp => {
1719 const date = new Date(exp.date);
1720 const dayName = dayNames[date.getDay()];
1721 dayTotals[dayName] = (dayTotals[dayName] || 0) + exp.cost;
1722 });
1723
1724 if (Object.keys(dayTotals).length > 0) {
1725 const sortedDays = Object.entries(dayTotals).sort((a, b) => b[1] - a[1]);
1726 mostExpensiveDay.textContent = sortedDays[0][0];
1727 cheapestDay.textContent = sortedDays[sortedDays.length - 1][0];
1728 } else {
1729 mostExpensiveDay.textContent = '--';
1730 cheapestDay.textContent = '--';
1731 }
1732 }
1733
1734 renderMealInsights() {
1735 const topMealType = document.getElementById('topMealType');

Callers 1

renderNewWidgetsMethod · 0.95

Calls 1

formatCurrencyFunction · 0.85

Tested by

no test coverage detected