Fix day offset by one

This commit is contained in:
Oracle 2026-06-17 14:52:30 +02:00
parent dc4efbea58
commit 5a0364976a
Signed by: Oracle
SSH key fingerprint: SHA256:x4/RtnjUyuHkdvmwNDsWSfcfF1V5PNr3OpriZqOvCX8
3 changed files with 49 additions and 17 deletions

View file

@ -7,7 +7,7 @@
},
"scripts": {
"dev": "astro dev",
"build": "astro build",
"build": "astro build && node scripts/fix-paths.mjs",
"preview": "astro preview",
"astro": "astro"
},

21
scripts/fix-paths.mjs Normal file
View file

@ -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/');

View file

@ -74,7 +74,7 @@ const TOKEN = import.meta.env.PUBLIC_ACCESS_TOKEN || '';
<div id="chart-weekly" class="chart"></div>
</div>
<div class="chart-card">
<h2 class="chart-title">Time Worked - Last Month</h2>
<h2 class="chart-title">Time Worked - This Month</h2>
<div id="chart-monthly" class="chart"></div>
</div>
</div>
@ -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)' },