From 56d8818581500a15859bbc9c7305d09a060a9b0e Mon Sep 17 00:00:00 2001 From: blaisadmin Date: Wed, 7 Oct 2026 20:31:16 -0400 Subject: [PATCH 1/2] Pass Mapbox Actions secret to deployment Compose steps --- .gitea/workflows/deploy.yml | 8 ++++++++ README.md | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index cbf6346..6d11a5b 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -36,12 +36,16 @@ jobs: docker run --rm -v "$PWD/frontend:/src:ro" -w /tmp/app node:22-alpine sh -lc "cp -a /src/. /tmp/app && npm ci && npm run build" - name: Validate dev compose config + env: + MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }} run: | set -e cd /docker/FlockPal-dev docker compose -f docker-compose.dev.yaml config --quiet - name: Deploy dev + env: + MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }} run: | set -e cd /docker/FlockPal-dev @@ -136,12 +140,16 @@ jobs: docker run --rm -v "$PWD/frontend:/src:ro" -w /tmp/app node:22-alpine sh -lc "cp -a /src/. /tmp/app && npm ci && npm run build" - name: Validate prod compose config + env: + MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }} run: | set -e cd /docker/FlockPal docker compose -f docker-compose.prod.yml config --quiet - name: Deploy prod + env: + MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }} run: | set -e cd /docker/FlockPal diff --git a/README.md b/README.md index 7127419..a288bcf 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ curl -H "Authorization: Bearer " https://your-host/api/metrics - `FRONTEND_URL` - `BACKEND_URL` - `VITE_API_BASE_URL` - - `MAPBOX_ACCESS_TOKEN` + - `MAPBOX_ACCESS_TOKEN` as a Gitea Actions secret for automated deployments (or in `.env` for manual Compose deployments) - `REDIS_URL` - `IMAGE_STORAGE_PROVIDER` - `S3_ENDPOINT` From 270652f1a8993012ea5a0a914233dd652a7cd264 Mon Sep 17 00:00:00 2001 From: blaisadmin Date: Wed, 7 Oct 2026 21:30:13 -0400 Subject: [PATCH 2/2] Fixed location timeline --- frontend/src/App.tsx | 19 ++++++++++--------- frontend/src/birdTimeline.ts | 26 ++++++++++++++++++++++++++ frontend/tests/birdTimeline.test.ts | 23 +++++++++++++++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 frontend/src/birdTimeline.ts create mode 100644 frontend/tests/birdTimeline.test.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b0e455f..e343f2c 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,3 +1,4 @@ +import { combineLocationOwnerMarkers } from './birdTimeline'; import { BehaviorJournal } from './BehaviorJournal'; import { useEffect, useMemo, useState, type CSSProperties, type Dispatch, type SetStateAction } from 'react'; import birdSilhouette from './assets/bird-silhouette.jpg'; @@ -1187,7 +1188,7 @@ const formatBirdTimelineTitle = (event: BirdTimelineEvent) => { } if (event.eventType === 'owner_changed') { - return 'Owner record changed'; + return 'Adopted'; } if (event.eventType === 'manual_note') { @@ -1210,7 +1211,7 @@ const formatBirdTimelineDescription = (event: BirdTimelineEvent) => { } if (event.eventType === 'owner_changed') { - return event.locationLabel ? `Owner changed at ${event.locationLabel}` : 'Owner changed'; + return event.locationLabel ? `Adopted at ${event.locationLabel}` : 'Adopted'; } if (event.eventType === 'manual_note') { @@ -1232,7 +1233,7 @@ const formatBirdTimelineSecondary = (event: BirdTimelineEvent) => { } if (event.eventType === 'owner_changed') { - return 'Owner changed without owner name'; + return 'Adoption recorded without owner names'; } return ''; @@ -1287,7 +1288,7 @@ const getBirdTimelineGraphLabel = (event: BirdTimelineEvent) => { } if (event.eventType === 'owner_changed') { - return 'Owner changed'; + return event.locationLabel ? `${compactTimelineLocationLabel(event.locationLabel)} — Adopted` : 'Adopted'; } if (event.eventType === 'transferred') { @@ -1387,7 +1388,7 @@ const compactTimelineLocationLabel = (label: string) => .join(', '); const getBirdTimelineGraphItems = (bird: Bird, events: BirdTimelineEvent[]): BirdTimelineGraphItem[] => { - const graphEvents: BirdTimelineGraphItem[] = sortBirdTimelineEvents(events) + const graphEvents: BirdTimelineGraphItem[] = sortBirdTimelineEvents(combineLocationOwnerMarkers(events, compactTimelineLocationLabel)) .reverse() .filter((event) => event.eventType !== 'profile_created') .map((event) => ({ @@ -8416,7 +8417,7 @@ function App() { }} > - + @@ -8466,8 +8467,8 @@ function App() { } /> - Owner changed - Records a change without owner names. + Adopted + Records an adoption without owner names. ) : null} @@ -8511,7 +8512,7 @@ function App() { ) : (
No timeline events yet - New location and owner changes for {selectedBird.name} will appear here. + New location changes and adoptions for {selectedBird.name} will appear here.
)} diff --git a/frontend/src/birdTimeline.ts b/frontend/src/birdTimeline.ts new file mode 100644 index 0000000..5a89a4e --- /dev/null +++ b/frontend/src/birdTimeline.ts @@ -0,0 +1,26 @@ +type LocationEvent = { + eventType: string; + eventDate: string; + createdAt: string; + locationLabel: string | null; + toWorkspaceId: number | null; +}; + +// Keep the owner marker when it already represents the same dated location. +// The original event list remains unchanged so notes and audit history are retained. +export const combineLocationOwnerMarkers = ( + events: T[], + normalizeLocation: (location: string) => string, +): T[] => { + const key = (event: T) => JSON.stringify([ + event.eventDate || event.createdAt.slice(0, 10), + normalizeLocation(event.locationLabel || '').trim().toLowerCase(), + event.toWorkspaceId, + ]); + const ownerLocations = new Set(events + .filter((event) => event.eventType === 'owner_changed' && event.locationLabel?.trim()) + .map(key)); + return events.filter((event) => + event.eventType !== 'location_updated' || !event.locationLabel?.trim() || !ownerLocations.has(key(event)), + ); +}; diff --git a/frontend/tests/birdTimeline.test.ts b/frontend/tests/birdTimeline.test.ts new file mode 100644 index 0000000..a85eb53 --- /dev/null +++ b/frontend/tests/birdTimeline.test.ts @@ -0,0 +1,23 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { combineLocationOwnerMarkers } from '../src/birdTimeline.ts'; + +const location = { id: 'location', eventType: 'location_updated', eventDate: '2023-04-07', createdAt: '2026-10-07T12:00:00Z', locationLabel: 'Warwick, RI, US', toWorkspaceId: 1 }; +const owner = { ...location, id: 'owner', eventType: 'owner_changed' }; +const normalize = (value: string) => value.replace('United States', 'US'); + +test('combines a same-date location and owner change without modifying saved events', () => { + const events = [location, { ...owner, locationLabel: 'Warwick, RI, United States' }]; + assert.deepEqual(combineLocationOwnerMarkers(events, normalize).map(event => event.id), ['owner']); + assert.equal(events.length, 2); +}); + +test('preserves different dates, locations, flocks, and standalone location changes', () => { + for (const other of [ + { ...owner, eventDate: '2023-04-08' }, + { ...owner, locationLabel: 'Providence, RI, US' }, + { ...owner, toWorkspaceId: 2 }, + { ...owner, locationLabel: null }, + ]) assert.equal(combineLocationOwnerMarkers([location, other], normalize).length, 2); + assert.deepEqual(combineLocationOwnerMarkers([location], normalize), [location]); +});