Skip to content

Correct Location statistics grouping and the Greece region-label duplicate without rewriting source data #573

Description

@stef-k

Problem and scope

The confirmed report concerns Location records containing both “East Macedonia
and Thrace” and “Eastern Macedonia and Thrace”, splitting region statistics.

This issue fixes that bounded label variation and deterministic statistics defects:
summary/detail grouping disagreement, inconsistent missing-parent treatment,
hidden orphan groups and multiple settlement representatives on tied timestamps.

Statistics remain based on recorded labels. Parent-scoped names are not universal
geographic identifiers. General country/settlement alias resolution is outside this
slice. This contract supersedes the earlier identity architecture proposal.

Fixed read-time rules

For Country, Region and Place, remove leading/trailing ASCII space U+0020 and
ASCII whitespace U+0009–U+000D. Null and resulting empty strings are missing.
Preserve case, Unicode composition, accents, internal whitespace and punctuation.
Use exact culture-independent comparison.

After trimming, when Country is exactly “Greece” and Region is exactly
“East Macedonia and Thrace”, use “Eastern Macedonia and Thrace” for statistics.
No other geographic substitution is authorized.

Sources checked 2026-09-05:

These sources support the two English labels for the Greek administrative region.
They do not verify any individual stored record. The rule applies only to the
Region component under the exact country label Greece, irrespective of provider
or record origin. Missing/different countries and other spellings remain unchanged.

Consistent statistics

Use these component tuples in every summary and detailed path:

  • Countries: Country, when present.
  • Regions: Country-or-missing plus Region, when Region is present.
  • Cities/places: Country-or-missing plus Region-or-missing plus Place,
    when Place is present.

Missing parents are not inferred. Do not conflate missing parents with named
parents. Summary counts equal corresponding detail group counts for the same
user/date scope. TotalLocations continues counting all scoped records.

Detail labels equal the grouping labels. Missing parent names remain empty strings
in existing DTOs. Preserve API shapes, field types, routes and default behavior:
no identityVersion, identity APIs or confirmed-identity-only totals.

Preserve all-time Timestamp and date-range LocalTimestamp semantics, including
existing inclusive date bounds. Aggregate visits and dates over corrected groups.
Keep the current home-country formula and country/region coordinate averages;
order floating-point average inputs by Location ID for repeatability.

Select exactly one settlement representative from the scoped group using relevant
timestamp descending, then Location ID descending. Do not join back to every row
sharing the maximum timestamp. Add deterministic tuple tie-breakers to output
ordering, independent of culture and encounter order.

Keep aggregation database-side and share the grouping definition within the
statistics implementation. Do not materialize all Location entities for summaries.

Hierarchy and compatibility

Update both User Timeline statistics renderers so every detailed region and
settlement appears exactly once, including when parents are missing.

Use presentation-only “Country not recorded” and “Region not recorded” sections
where necessary. Do not add synthetic parents to API arrays or visited counts.
Encode labels at HTML boundaries. Preserve existing map-navigation behavior.

Existing statistics endpoints and released Mobile receive the corrected ordinary
counts through unchanged contracts. Document that parent scoping can increase
counts and the region correction can decrease them.

Search, Bulk Edit Notes, dropdowns, preview and update retain their existing
substring/exact-name semantics. Statistics labels are not new search identifiers.

Preservation and limitations

Read-time correction only: no persisted fields, schema migration or data rewrite.
Preserve original provider/manual/imported labels, all #572 mappings, FullAddress,
ProviderAddressLine1, feature metadata and existing export/import behavior.
Do not change Mapbox selection or mapping.

Historical Place/Region administrative ambiguity remains. Same-named settlements
within identical recorded parents cannot be distinguished from current strings.
Different labels may still describe one entity. Do not introduce speculative
merges or replace useful statistics with unresolved observations.

Exclude fuzzy matching, proximity, global word replacement, case/accent folding,
geographic catalogs, generic alias infrastructure, identity/assignment tables,
provider synchronization, raw responses, administrative UI and extra requests.
This single source-backed rule is not an extensible geographic catalog.

Acceptance and validation

  • The two exact region labels under Greece produce one region group, combined
    visits and consistent city nesting; original stored values remain unchanged.
  • The rule does not apply under missing/different countries or to other spellings.
  • Same-named regions/places with different recorded parents remain separate in
    both summary and details.
  • Null/empty/ASCII-whitespace parents follow one rule and never hide child groups.
  • Tied timestamps return one settlement representative, selected by Location ID.
  • Existing PostgreSQL statistics tests prove membership, summary/detail agreement,
    user scoping and one date range with a compact synthetic dataset.
  • Existing client tests prove orphan rendering, exactly-once display and encoding
    through production rendering behavior. Do not duplicate the service matrix.
  • Update Timeline statistics documentation and Unreleased notes with the rule,
    sources, changed counts and string-only limitations.
  • Run focused tests and complete-scope Code Guard, then independent review and
    normal exact-head CI. Browser evidence is needed only for material behavior not
    credibly covered below that boundary.

No production access, provider contact, coordinate queries, Mobile implementation
or historical correction execution is authorized.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions