← All repositories

reportage

A life-logging app for iPhone

git clone https://code.inqk.net/reportage.git


commit cd9748d05fb6895770f8508b6f24de25ee6eb351
parent 08d8e9842a7d29600ee6b733f3103baad681c849
Author: Michael Camilleri <[email protected]>
Date:   Wed,  4 Nov 2026 10:09:30 +0900

List customised venues in Your Places

At present, 'Your Plaes' does not list places from Apple's directory
that the user has customised. This might confuse a user who considers
that a place they have customised is, in some sense, their place.

This commit counts a venue as one of the user's places once it has
been renamed or given a narrative form, so it is listed with the places
the user named themselves and ranked the same way. Venues that have
only been picked still stay out, which keeps one-off visits from
crowding the list. Vocabulary entries now record whether a directory
place has been renamed, so the picker can tell without the token.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Diffstat

MNotes/Design.md | 13++++++++-----
MReportage/Views/Survey/PlacePicker.swift | 11++++++-----
MShared/Persistence/ReportStore.swift | 3++-
MShared/Persistence/Vocabulary.swift | 4++++
MTests/Unit/PlacePickerTests.swift | 23+++++++++++++++++++++++
MTests/Unit/ReportStoreTests.swift | 31+++++++++++++++++++++++++++++++

6 files changed, 74 insertions(+), 11 deletions(-)

diff --git a/Notes/Design.md b/Notes/Design.md

@@ -363,11 +363,14 @@ Candidates, in order:
 1. **The user's saved places**: the places they named themselves, ranked by
    distance from the current location, then by use and recency. This needs no
    network, and covers most answers: 14 saved names account for 80% of the
-   archive's location answers. As in Reporter, a venue picked from the
-   directory isn't added to this list. Venues answered before come back when
-   the directory lists them again, merged with their token, or in a search. A
-   place is saved when its token has no external ID; in the archive, no place
-   was used both ways.
+   archive's location answers. As in Reporter, picking a venue from the
+   directory doesn't add it to this list, so venues answered once don't crowd
+   it. A venue joins the list once the user renames it or gives it a
+   narrative form, since that marks it as one of theirs, such as their
+   workplace. Other venues answered before come back when the directory lists
+   them again, merged with their token, or in a search. A place is saved when
+   its token has no external ID, or its name isn't the directory's, or it has
+   a narrative form; in the archive, no place was used both ways.
 2. **Nearby places** from `MKLocalPointsOfInterestRequest`, when nothing in
    history is close.
 3. **Search** across history and MapKit together. MapKit matches queries in

diff --git a/Reportage/Views/Survey/PlacePicker.swift b/Reportage/Views/Survey/PlacePicker.swift

@@ -429,9 +429,10 @@ final class PlacePicker {
 }
 
 extension VocabularyEntry {
-    /// Whether the user saved the place by name, rather than answering with
-    /// a venue from a directory. As in Reporter, only saved places are listed
-    /// without a search: a venue answered before comes back when the
-    /// directory lists it again, or when it's searched for.
-    var isSavedPlace: Bool { externalID == nil }
+    /// Whether the place is one the user has made their own: saved by name,
+    /// or a venue from a directory they've renamed or given a narrative
+    /// form. Only these are listed without a search, so venues answered once
+    /// don't crowd the list: any other venue answered before comes back when
+    /// the directory lists it again, or when it's searched for.
+    var isSavedPlace: Bool { externalID == nil || isRenamed || narrativeForm != nil }
 }

diff --git a/Shared/Persistence/ReportStore.swift b/Shared/Persistence/ReportStore.swift

@@ -276,7 +276,8 @@ struct ReportStore: Sendable {
                     useCount: 0,
                     coordinate: token.place?.coordinate,
                     externalID: token.place?.externalID,
-                    narrativeForm: token.narrativeForm
+                    narrativeForm: token.narrativeForm,
+                    isRenamed: token.place?.externalID != nil && !token.isNamedByDirectory
                 )
             }
             return entries

diff --git a/Shared/Persistence/Vocabulary.swift b/Shared/Persistence/Vocabulary.swift

@@ -18,6 +18,9 @@ struct VocabularyEntry: Identifiable, Hashable, Sendable {
     var locality: String?
     /// How the token reads in a narrative, when that differs from `text`.
     var narrativeForm: String?
+    /// For places from a directory: whether the user has renamed it, so its
+    /// name is no longer the directory's.
+    var isRenamed = false
     /// The tokens merged into this one, directly or along a chain, most
     /// used first. Their names still find it.
     var merged: [MergedToken] = []
@@ -146,6 +149,7 @@ enum Vocabulary {
                     externalID: token.place?.externalID,
                     locality: localities[token.id],
                     narrativeForm: token.narrativeForm,
+                    isRenamed: token.place?.externalID != nil && !token.isNamedByDirectory,
                     merged: (merged[token.id] ?? []).sorted { lhs, rhs in
                         lhs.useCount != rhs.useCount
                             ? lhs.useCount > rhs.useCount

diff --git a/Tests/Unit/PlacePickerTests.swift b/Tests/Unit/PlacePickerTests.swift

@@ -252,6 +252,29 @@ struct PlacePickerTests {
         #expect(ids(picker)[.yours] == ["venue"])
     }
 
+    @Test("Venues the user has renamed or given a narrative form are listed as theirs")
+    func customisedVenues() async {
+        func venue(_ id: String, uses: Int, at metres: Double) -> VocabularyEntry {
+            Self.entry(
+                id, id.capitalized, uses: uses, at: Self.north(metres),
+                externalID: ExternalPlaceID(source: .mapKit, value: id))
+        }
+        var renamed = venue("renamed", uses: 30, at: 100)
+        renamed.isRenamed = true
+        var described = venue("described", uses: 10, at: 200)
+        described.narrativeForm = "the office"
+        let plain = venue("plain", uses: 60, at: 50)
+        let picker = makePicker(entries: Self.entries + [renamed, described, plain])
+
+        // Without a location, they're listed with the saved places.
+        #expect(ids(picker)[.yours] == ["home", "cafe", "bar", "office", "unplaced", "renamed", "described"])
+
+        picker.setLocation(LocationContext(coordinate: Self.here))
+        await picker.settle()
+        // Home and the described venue share a band, and Home is used more.
+        #expect(ids(picker) == [.yours: ["bar", "renamed", "cafe", "home", "described"]])
+    }
+
     @Test("Typing a place's name outside its region adds a new place with that name")
     func regions() throws {
         let entries = [

diff --git a/Tests/Unit/ReportStoreTests.swift b/Tests/Unit/ReportStoreTests.swift

@@ -236,6 +236,37 @@ struct ReportStoreTests {
         #expect(byID["U"]?.externalID == nil)
     }
 
+    @Test("A directory place counts as renamed once its name isn't the directory's")
+    func renamedPlace() async throws {
+        func venue(_ id: String, _ text: String) -> Token {
+            Token(
+                id: id, questionID: "L", text: text,
+                place: PlaceDetails(
+                    names: [LocalisedName(language: "en", text: "Acme Tower")],
+                    externalID: ExternalPlaceID(source: .mapKit, value: id)),
+                modifiedAt: Date(timeIntervalSince1970: 0))
+        }
+        let tokens = [
+            venue("D", "Acme Tower"),
+            venue("R", "Work"),
+            Token(
+                id: "S", questionID: "L", text: "Home", place: PlaceDetails(),
+                modifiedAt: Date(timeIntervalSince1970: 0)),
+        ]
+        let responses = tokens.map {
+            Response(questionID: "L", prompt: "P", value: .place(PlaceAnswer(tokenID: $0.id)))
+        }
+        for (number, response) in responses.enumerated() {
+            try await store.insert(
+                Self.report(number + 1, responses: [response]), newTokens: number == 0 ? tokens : [])
+        }
+        let entries = try #require(try await store.vocabulary(for: ["L"])["L"])
+        let byID = Dictionary(uniqueKeysWithValues: entries.map { ($0.id, $0) })
+        #expect(byID["D"]?.isRenamed == false)
+        #expect(byID["R"]?.isRenamed == true)
+        #expect(byID["S"]?.isRenamed == false)
+    }
+
     @Test("A place has the locality of the last report that used it")
     func placeLocality() async throws {
         let home = Token(