From 5a0364976a6c06220056b0bbfdab5da72f20c308 Mon Sep 17 00:00:00 2001 From: Oracle Date: Wed, 17 Jun 2026 14:52:30 +0200 Subject: [PATCH] Fix day offset by one --- package.json | 2 +- scripts/fix-paths.mjs | 21 +++++++++++++++++++++ src/pages/index.astro | 43 +++++++++++++++++++++++++++---------------- 3 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 scripts/fix-paths.mjs diff --git a/package.json b/package.json index 17d25b4..1c93e86 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "scripts": { "dev": "astro dev", - "build": "astro build", + "build": "astro build && node scripts/fix-paths.mjs", "preview": "astro preview", "astro": "astro" }, diff --git a/scripts/fix-paths.mjs b/scripts/fix-paths.mjs new file mode 100644 index 0000000..0c3a8a5 --- /dev/null +++ b/scripts/fix-paths.mjs @@ -0,0 +1,21 @@ +import { readFileSync, writeFileSync, readdirSync } from 'fs'; +import { join } from 'path'; + +const dist = join(import.meta.dirname, '..', 'dist'); + +function fixFile(filePath) { + let content = readFileSync(filePath, 'utf-8'); + // Replace /_astro/ with ./_astro/ + content = content.replace(/\/_astro\//g, './_astro/'); + // Replace /favicon with ./favicon + content = content.replace(/href="\/favicon/g, 'href="./favicon'); + writeFileSync(filePath, content, 'utf-8'); +} + +for (const file of readdirSync(dist)) { + if (file.endsWith('.html')) { + fixFile(join(dist, file)); + } +} + +console.log('Fixed relative paths in dist/'); diff --git a/src/pages/index.astro b/src/pages/index.astro index 6b0f973..f4c24a8 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -74,7 +74,7 @@ const TOKEN = import.meta.env.PUBLIC_ACCESS_TOKEN || '';
-

Time Worked - Last Month

+

Time Worked - This Month

@@ -167,16 +167,25 @@ const TOKEN = import.meta.env.PUBLIC_ACCESS_TOKEN || ''; function getDayKey(dateStr) { var d = new Date(dateStr); - return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); + var y = d.getUTCFullYear(); + var m = String(d.getUTCMonth() + 1).padStart(2, '0'); + var day = String(d.getUTCDate()).padStart(2, '0'); + return y + '-' + m + '-' + day; } - function getDayLabel(dateStr) { - var d = new Date(dateStr); + function getDayLabel(d) { return String(d.getDate()).padStart(2, '0') + '.' + String(d.getMonth() + 1).padStart(2, '0'); } + function getUTCDayKey(d) { + var y = d.getUTCFullYear(); + var m = String(d.getUTCMonth() + 1).padStart(2, '0'); + var day = String(d.getUTCDate()).padStart(2, '0'); + return y + '-' + m + '-' + day; + } + function truncateTitle(t, max) { - max = max || 40; + max = max || 120; return t.length > max ? t.substring(0, max) + '...' : t; } @@ -198,6 +207,8 @@ const TOKEN = import.meta.env.PUBLIC_ACCESS_TOKEN || ''; for (var i = 0; i < timesData.length; i++) { var entry = timesData[i]; + var repoKey = entry.repository_url || (entry.issue && entry.issue.repository_url) || (entry.issue && entry.issue.repository && entry.issue.repository.full_name) || ''; + if (repoKey.indexOf('VectorSearchMedia') === -1) continue; var timeSec = entry.time || 0; var created = new Date(entry.created).getTime(); @@ -238,20 +249,21 @@ const TOKEN = import.meta.env.PUBLIC_ACCESS_TOKEN || ''; }; // Weekly chart (14 days) - var weeklyData = []; + var weeklyData = []; var weeklyLabels = []; var now = new Date(); for (var i = 13; i >= 0; i--) { var d = new Date(now); d.setDate(d.getDate() - i); - var key = getDayKey(d.toISOString()); - weeklyLabels.push(String(d.getDate()).padStart(2, '0') + '.' + String(d.getMonth() + 1).padStart(2, '0')); + var key = getUTCDayKey(d); + var label = String(d.getUTCDate()).padStart(2, '0') + '.' + String(d.getUTCMonth() + 1).padStart(2, '0'); + weeklyLabels.push(label); weeklyData.push((dayMap[key] || 0) / 3600); } new ApexCharts(document.querySelector("#chart-weekly"), { chart: chartBase.chart, theme: chartBase.theme, - xaxis: { type: 'category', labels: { formatter: function(val) { return weeklyLabels[parseInt(val) || 0]; }, style: { colors: '#a0a0b8', fontSize: '11px' } }, axisTicks: { show: true }, axisBorder: { show: true, color: 'rgba(139, 92, 246, 0.2)' } }, + xaxis: { categories: weeklyLabels, labels: { style: { colors: '#a0a0b8', fontSize: '11px' } }, axisTicks: { show: true }, axisBorder: { show: true, color: 'rgba(139, 92, 246, 0.2)' } }, yaxis: { labels: { formatter: function(val) { return val ? val.toFixed(1) : '0'; } } }, series: [{ name: 'Hours', data: weeklyData }], stroke: chartBase.stroke, @@ -268,14 +280,15 @@ const TOKEN = import.meta.env.PUBLIC_ACCESS_TOKEN || ''; for (var i = 29; i >= 0; i--) { var d = new Date(now); d.setDate(d.getDate() - i); - var key = getDayKey(d.toISOString()); - monthlyLabels.push(getDayLabel(d.toISOString())); + var key = getUTCDayKey(d); + var label = String(d.getUTCDate()).padStart(2, '0') + '.' + String(d.getUTCMonth() + 1).padStart(2, '0'); + monthlyLabels.push(label); monthlyData.push((dayMap[key] || 0) / 3600); } new ApexCharts(document.querySelector("#chart-monthly"), { chart: chartBase.chart, theme: chartBase.theme, - xaxis: { type: 'category', labels: { formatter: function(val) { return monthlyLabels[parseInt(val) || 0]; }, style: { colors: '#a0a0b8', fontSize: '11px' } }, axisTicks: { show: true }, axisBorder: { show: true, color: 'rgba(139, 92, 246, 0.2)' } }, + xaxis: { categories: monthlyLabels, labels: { style: { colors: '#a0a0b8', fontSize: '11px' } }, axisTicks: { show: true }, axisBorder: { show: true, color: 'rgba(139, 92, 246, 0.2)' } }, yaxis: { labels: { formatter: function(val) { return val ? val.toFixed(1) : '0'; } } }, series: [{ name: 'Hours', data: monthlyData }], stroke: chartBase.stroke, @@ -294,8 +307,7 @@ const TOKEN = import.meta.env.PUBLIC_ACCESS_TOKEN || ''; theme: { mode: 'dark' }, series: [{ name: 'Hours', data: issueHours }], plotOptions: { bar: { horizontal: true, borderRadius: 4 } }, - xaxis: { categories: issueTitles.map(truncateTitle), labels: { style: { colors: '#a0a0b8', fontSize: '11px' } } }, - yaxis: { labels: { style: { colors: '#a0a0b8' } } }, + xaxis: { categories: issueTitles, titles: issueTitles.map(truncateTitle), labels: { show: true,style: { colors: '#a0a0b8', fontSize: '11px' }, rotate: 0 }, yaxisLabel: { ShowOverflows: true } }, colors: ['#22c55e'], fill: { type: 'solid', opacity: 0.8 }, grid: { borderColor: 'rgba(139, 92, 246, 0.15)' }, @@ -312,8 +324,7 @@ const TOKEN = import.meta.env.PUBLIC_ACCESS_TOKEN || ''; theme: { mode: 'dark' }, series: [{ name: 'Hours', data: prHours }], plotOptions: { bar: { horizontal: true, borderRadius: 4 } }, - xaxis: { categories: prTitles.map(truncateTitle), labels: { style: { colors: '#a0a0b8', fontSize: '11px' } } }, - yaxis: { labels: { style: { colors: '#a0a0b8' } } }, + xaxis: { categories: prTitles, titles: prTitles.map(truncateTitle), labels: { show: true,style: { colors: '#a0a0b8', fontSize: '11px' }, rotate: 0 }, yaxisLabel: { ShowOverflows: true } }, colors: ['#3b82f6'], fill: { type: 'solid', opacity: 0.8 }, grid: { borderColor: 'rgba(139, 92, 246, 0.15)' },