mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
feat(journey): create draft entries from gallery photos
Groups the gallery photos on no entry by local day, then by time gap and distance, names each group through the geocoder (capped per preview, with the country or the day as fallback) and writes the groups the traveller keeps as draft entries with their photos in one transaction. Photos put on an entry meanwhile or named twice are left out and reported; existing entries are never touched. REST routes under /api/journeys/:id/entries/from-photos and the MCP tools preview_journey_entries_from_photos and create_journey_entries_from_photos share one service and the journey edit right (#1920).
This commit is contained in:
@@ -4,6 +4,8 @@ import { DawarichVisitSuggestions } from '../../../src/db/entities/DawarichVisit
|
||||
import { JourneyBookRevisions } from '../../../src/db/entities/JourneyBookRevisions.entity';
|
||||
import { JourneyBooks } from '../../../src/db/entities/JourneyBooks.entity';
|
||||
import { JourneyEntries } from '../../../src/db/entities/JourneyEntries.entity';
|
||||
import { JourneyPhotos } from '../../../src/db/entities/JourneyPhotos.entity';
|
||||
import { TrekPhotos } from '../../../src/db/entities/TrekPhotos.entity';
|
||||
import { TripJournalLinks } from '../../../src/db/entities/TripJournalLinks.entity';
|
||||
import { VacayHolidayCalendars } from '../../../src/db/entities/VacayHolidayCalendars.entity';
|
||||
import { VacayShares } from '../../../src/db/entities/VacayShares.entity';
|
||||
@@ -481,6 +483,35 @@ const journeyCases: ParityCase[] = [
|
||||
},
|
||||
expect: [{ event: 'journey:updated', user: 'actor' }],
|
||||
},
|
||||
{
|
||||
tool: 'create_journey_entries_from_photos',
|
||||
needs: ['journey'],
|
||||
setup: async (s, app) => {
|
||||
const photoId = await insertRow(ormOf(app), TrekPhotos, {
|
||||
provider: 'local',
|
||||
owner: s.owner.id,
|
||||
file_path: 'journey/p.jpg',
|
||||
taken_at: `${DAY}T09:00:00Z`,
|
||||
lat: 48.854,
|
||||
lng: 2.3326,
|
||||
});
|
||||
const galleryId = await insertRow(ormOf(app), JourneyPhotos, {
|
||||
journey: s.journey.id,
|
||||
photo: photoId,
|
||||
sort_order: 0,
|
||||
created_at: Date.now(),
|
||||
});
|
||||
keep(s, 'galleryFromPhoto', galleryId);
|
||||
},
|
||||
args: (s) => ({ journeyId: s.journey.id, groups: [{ photoIds: [kept(s, 'galleryFromPhoto')], title: 'Paris' }] }),
|
||||
rest: {
|
||||
method: 'post',
|
||||
path: (s) => `/api/journeys/${s.journey.id}/entries/from-photos`,
|
||||
body: (s) => ({ groups: [{ photoIds: [kept(s, 'galleryFromPhoto')], title: 'Paris' }] }),
|
||||
},
|
||||
// One per draft written, after the commit.
|
||||
expect: [{ event: 'journey:entry:created', user: 'actor' }],
|
||||
},
|
||||
{
|
||||
tool: 'add_journey_contributor',
|
||||
needs: ['journey', 'member'],
|
||||
|
||||
Reference in New Issue
Block a user