place-contrib: community hours in the details' own shape, and no origin rows for collection copies

Community opening hours laid over OSM details now go through the same parser
as OSM's own, so they arrive as one line per day with open-now and the periods,
and a community description lands in the details' summary. A place copied from
a collection no longer records its values as an import: without an origin row a
value is never sent anyway, and a later edit marks only the fields it changes.
This commit is contained in:
Maurice
2026-10-30 21:04:15 +01:00
parent f01ffc2c67
commit 04458bee12
8 changed files with 19 additions and 23 deletions
@@ -7,7 +7,6 @@ import { PermissionsService } from '../permissions/permissions.service';
import { RealtimeService } from '../realtime/realtime.service';
import { isUploadedPlaceImage } from '../places/place-image';
import { PlacesService } from '../places/places.service';
import { PlaceOriginsService } from '../places/place-origins.service';
import { StorageService } from '../storage/storage.service';
import { Collections } from '../../db/entities/Collections.entity';
import { CollectionsRepository, type CollectionPlaceRow } from '../../db/repositories/Collections.repository';
@@ -131,7 +130,6 @@ export class CollectionsService {
@InjectRepository(Users) private readonly users: UsersRepository,
private readonly placeImport: PlaceImportService,
private readonly places: PlacesService, // the journey hook of every place copyToTrip adds
private readonly origins: PlaceOriginsService,
) {}
/**
@@ -1188,8 +1186,6 @@ export class CollectionsService {
created.push({ id: newPlaceId, source_id: s.id });
}
});
// A copied value is the collection's, not typed in this write: recorded as an import, never shared.
if (created.length > 0) await this.origins.recordImported(created.map(({ id }) => id));
const rows = await Promise.all(created.map(({ id }) => this.tripPlaces.findWithTagsAndRatings(id))); // reads only
for (const [i, place] of rows.entries()) {
if (place) events.emit('place:created', { place }); // as the place routes send it
+11 -2
View File
@@ -1,3 +1,4 @@
import { buildOsmDetails } from './maps.helpers';
import { trekCommunityByKeys, type TrekCommunityValues } from './trek-places.client';
import { normalizePlaceWebsite } from '@trek/shared';
@@ -26,8 +27,16 @@ export function withCommunityValues(
if (website) out.website = website;
if (values.contact?.phone) out.phone = values.contact.phone;
if (values.contact?.email) out.email = values.contact.email;
if (values.hours?.osm) out.opening_hours = values.hours.osm;
if (values.description?.text) out.description = values.description.text;
if (values.hours?.osm) {
// The same shape OSM's own hours take in the details: one line per day, open now, the periods.
const hours = buildOsmDetails({ opening_hours: values.hours.osm }, '', '');
if (hours.opening_hours) {
out.opening_hours = hours.opening_hours;
out.open_now = hours.open_now;
out.opening_periods = hours.opening_periods;
}
}
if (values.description?.text) out.summary = values.description.text;
if (typeof values.community.version === 'number') out.community_version = values.community.version;
return out;
}
+1 -1
View File
@@ -106,7 +106,7 @@ import { MulterModule } from '@nestjs/platform-express';
],
controllers: [PlacesController],
providers: [PlacesService, PlacesMcp, PlacesRpc, PlaceOriginsService],
// The origin bookkeeping too: the copy from a collection and the booking import write places as well.
// The origin bookkeeping too: the booking import writes places as well.
exports: [PlacesService, PlaceOriginsService],
})
export class PlacesModule {}