feat: Update contribution tracking to use backend-provided weekday values and enhance UI components

This commit is contained in:
olli 2025-11-13 15:23:53 +01:00
parent c1278d2e45
commit cec1bdead6
7 changed files with 72 additions and 25 deletions

View File

@ -8,6 +8,7 @@
icon="pi pi-upload" icon="pi pi-upload"
@click="showUploadDialog = true" @click="showUploadDialog = true"
severity="success" severity="success"
class="ml-auto"
outlined outlined
/> />
</div> </div>

View File

@ -124,10 +124,13 @@ const contributionGrid = computed(() => {
firstSunday.setDate(firstSunday.getDate() - 1) firstSunday.setDate(firstSunday.getDate() - 1)
} }
// Create a map of dates to contribution counts // Backend already provides weekday values (0=Sun, 6=Sat), use them directly
const contributionMap = {} const contributionMap = {}
contributionData.value.forEach(day => { contributionData.value.forEach(day => {
contributionMap[day.date] = day.count contributionMap[day.date] = {
count: day.count,
weekday: day.weekday // Use weekday from backend
}
}) })
let col = 1 let col = 1
@ -136,12 +139,15 @@ const contributionGrid = computed(() => {
while (currentDate <= lastDay || currentDate.getDay() !== 0) { while (currentDate <= lastDay || currentDate.getDay() !== 0) {
const dateStr = currentDate.toISOString().split('T')[0] const dateStr = currentDate.toISOString().split('T')[0]
const weekday = currentDate.getDay() // 0 = Sunday, 6 = Saturday const contributionInfo = contributionMap[dateStr]
// Use weekday from backend if available, otherwise calculate it
const weekday = contributionInfo ? contributionInfo.weekday : currentDate.getDay()
const row = weekday + 1 // Grid row: 1-7 (Sunday-Saturday) const row = weekday + 1 // Grid row: 1-7 (Sunday-Saturday)
// Only add cells for the current year // Only add cells for the current year
if (currentDate.getFullYear() === currentYear.value) { if (currentDate.getFullYear() === currentYear.value) {
const count = contributionMap[dateStr] || 0 const count = contributionInfo ? contributionInfo.count : 0
const date = new Date(currentDate) const date = new Date(currentDate)
grid.push({ grid.push({
@ -301,6 +307,10 @@ async function loadContributions() {
const data = await response.json() const data = await response.json()
contributionData.value = data.contributions || [] contributionData.value = data.contributions || []
// Debug: Log first few contributions to check weekday values
console.log('Loaded contributions sample:', contributionData.value.slice(0, 5))
console.log('Total contributions:', contributionData.value.length)
} catch (err) { } catch (err) {
console.error('Error loading contributions:', err) console.error('Error loading contributions:', err)
error.value = err.message error.value = err.message
@ -438,7 +448,11 @@ defineExpose({
} }
.intensity-0 { .intensity-0 {
background-color: var(--surface-200); background-color: #ebedf0;
}
:global(.dark) .intensity-0 {
background-color: #161b22;
} }
.intensity-1 { .intensity-1 {
@ -457,10 +471,6 @@ defineExpose({
background-color: #216e39; background-color: #216e39;
} }
:global(.dark) .intensity-0 {
background-color: var(--surface-700);
}
.legend { .legend {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -563,9 +563,14 @@
:modal="true" :modal="true"
:style="{ width: '1400px' }" :style="{ width: '1400px' }"
> >
<TabView> <Tabs value="0">
<TabList>
<Tab value="0">Projektdaten</Tab>
<Tab value="1">Git Repositories</Tab>
</TabList>
<TabPanels>
<!-- Project Data Tab --> <!-- Project Data Tab -->
<TabPanel header="Projektdaten"> <TabPanel value="0">
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<!-- Basic Information --> <!-- Basic Information -->
<div class="p-4 border-round border-1 surface-border"> <div class="p-4 border-round border-1 surface-border">
@ -677,7 +682,7 @@
</TabPanel> </TabPanel>
<!-- Git Repository Tab --> <!-- Git Repository Tab -->
<TabPanel header="Git Repositories"> <TabPanel value="1">
<div v-if="gitRepositories.length === 0" class="text-center py-8 text-500"> <div v-if="gitRepositories.length === 0" class="text-center py-8 text-500">
<i class="pi pi-github text-6xl mb-3"></i> <i class="pi pi-github text-6xl mb-3"></i>
<p>Keine Git-Repositories verknüpft</p> <p>Keine Git-Repositories verknüpft</p>
@ -742,7 +747,8 @@
</div> </div>
</div> </div>
</TabPanel> </TabPanel>
</TabView> </TabPanels>
</Tabs>
<template #footer> <template #footer>
<Button label="Schließen" @click="viewDialog = false" /> <Button label="Schließen" @click="viewDialog = false" />
@ -765,7 +771,10 @@ import DatePicker from 'primevue/datepicker'
import InputNumber from 'primevue/inputnumber' import InputNumber from 'primevue/inputnumber'
import RadioButton from 'primevue/radiobutton' import RadioButton from 'primevue/radiobutton'
import Tag from 'primevue/tag' import Tag from 'primevue/tag'
import TabView from 'primevue/tabview' import Tabs from 'primevue/tabs'
import TabList from 'primevue/tablist'
import Tab from 'primevue/tab'
import TabPanels from 'primevue/tabpanels'
import TabPanel from 'primevue/tabpanel' import TabPanel from 'primevue/tabpanel'
import DataTable from 'primevue/datatable' import DataTable from 'primevue/datatable'
import Column from 'primevue/column' import Column from 'primevue/column'

View File

@ -8,6 +8,8 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put; use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Delete; use ApiPlatform\Metadata\Delete;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use App\Repository\GitRepositoryRepository; use App\Repository\GitRepositoryRepository;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -25,6 +27,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
normalizationContext: ['groups' => ['git_repo:read']], normalizationContext: ['groups' => ['git_repo:read']],
denormalizationContext: ['groups' => ['git_repo:write']] denormalizationContext: ['groups' => ['git_repo:write']]
)] )]
#[ApiFilter(SearchFilter::class, properties: ['project' => 'exact'])]
class GitRepository class GitRepository
{ {
#[ORM\Id] #[ORM\Id]

View File

@ -100,10 +100,14 @@ class GitHubService
$dayKey = $date->format('Y-m-d'); $dayKey = $date->format('Y-m-d');
if (!isset($dailyContributions[$dayKey])) { if (!isset($dailyContributions[$dayKey])) {
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
$phpWeekday = (int)$date->format('N'); // 1-7
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
$dailyContributions[$dayKey] = [ $dailyContributions[$dayKey] = [
'date' => $dayKey, 'date' => $dayKey,
'count' => 0, 'count' => 0,
'weekday' => (int)$date->format('N') 'weekday' => $jsWeekday
]; ];
} }
@ -119,10 +123,14 @@ class GitHubService
$dayKey = $date->format('Y-m-d'); $dayKey = $date->format('Y-m-d');
if (!isset($dailyContributions[$dayKey])) { if (!isset($dailyContributions[$dayKey])) {
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
$phpWeekday = (int)$date->format('N'); // 1-7
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
$dailyContributions[$dayKey] = [ $dailyContributions[$dayKey] = [
'date' => $dayKey, 'date' => $dayKey,
'count' => 0, 'count' => 0,
'weekday' => (int)$date->format('N') 'weekday' => $jsWeekday
]; ];
} }
} }

View File

@ -119,10 +119,14 @@ class GitService
$dayKey = $date->format('Y-m-d'); $dayKey = $date->format('Y-m-d');
if (!isset($dailyContributions[$dayKey])) { if (!isset($dailyContributions[$dayKey])) {
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
$phpWeekday = (int)$date->format('N'); // 1-7
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
$dailyContributions[$dayKey] = [ $dailyContributions[$dayKey] = [
'date' => $dayKey, 'date' => $dayKey,
'count' => 0, 'count' => 0,
'weekday' => (int)$date->format('N') // 1 = Monday, 7 = Sunday 'weekday' => $jsWeekday
]; ];
} }
@ -137,10 +141,14 @@ class GitService
$dayKey = $date->format('Y-m-d'); $dayKey = $date->format('Y-m-d');
if (!isset($dailyContributions[$dayKey])) { if (!isset($dailyContributions[$dayKey])) {
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
$phpWeekday = (int)$date->format('N'); // 1-7
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
$dailyContributions[$dayKey] = [ $dailyContributions[$dayKey] = [
'date' => $dayKey, 'date' => $dayKey,
'count' => 0, 'count' => 0,
'weekday' => (int)$date->format('N') 'weekday' => $jsWeekday
]; ];
} }
} }

View File

@ -101,10 +101,14 @@ class GiteaService
$dayKey = $date->format('Y-m-d'); $dayKey = $date->format('Y-m-d');
if (!isset($dailyContributions[$dayKey])) { if (!isset($dailyContributions[$dayKey])) {
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
$phpWeekday = (int)$date->format('N'); // 1-7
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
$dailyContributions[$dayKey] = [ $dailyContributions[$dayKey] = [
'date' => $dayKey, 'date' => $dayKey,
'count' => 0, 'count' => 0,
'weekday' => (int)$date->format('N') 'weekday' => $jsWeekday
]; ];
} }
@ -116,10 +120,14 @@ class GiteaService
$dayKey = $date->format('Y-m-d'); $dayKey = $date->format('Y-m-d');
if (!isset($dailyContributions[$dayKey])) { if (!isset($dailyContributions[$dayKey])) {
// Convert PHP weekday (1=Mon, 7=Sun) to JS weekday (0=Sun, 6=Sat)
$phpWeekday = (int)$date->format('N'); // 1-7
$jsWeekday = $phpWeekday % 7; // 0=Sun, 1=Mon, ..., 6=Sat
$dailyContributions[$dayKey] = [ $dailyContributions[$dayKey] = [
'date' => $dayKey, 'date' => $dayKey,
'count' => 0, 'count' => 0,
'weekday' => (int)$date->format('N') 'weekday' => $jsWeekday
]; ];
} }
} }