Skip to content

V1-18: Search, place first #656

Open

Description

@kelvinkipruto

Type: AFK. Can be built and merged without a decision.

Owner: koechkevin. Order: 9 of 12 for this owner, after #669 and before #657. Track: public site. Build order: #672

Part of PromiseTracker v3, version 1. Specification: docs/spec/promisetracker-v3-system-specification.md. Section numbers below refer to it.

What to build

The payload-search adapter, built on Payload's search plugin (@payloadcms/plugin-search), and
the search page. A search for a place returns everyone who represents it, from the president down.
Section 7.11 describes the design (D44).

Start here

  • Read first: sections 7.11, 16.2 and 18 of the specification.
  • Code goes in: the payloadSearch adapter in plugins/core/src/adapters.ts, which is a stub today. The search handler in apps/cms/src/api/v1.ts. The page in apps/site/src/app/(site).
  • Already there: unaccent and pg_trgm are installed by the first migration and checked at start-up in apps/cms/src/extensions.ts. @payloadcms/plugin-search is not in the catalog in pnpm-workspace.yaml yet.
  • Migration: Yes. The search table and the trigram index.
  • How to work: AGENTS.md, section "Working on an issue".

Acceptance criteria

  • @payloadcms/plugin-search keeps a search collection in step with claims, actors, areas
    and topics, with one entry per language and a localized title
  • A record is indexed in a language only when it is published in that language. skipSync
    applies the publishing rules in section 8, and a record that leaves the public site leaves
    the index
  • Priorities put areas and actors above claims
  • beforeSync adds the country, the kind of record and its link, so results need no second
    query
  • The search title has a trigram index, added by migration. unaccent makes "Senegal" find
    "Sénégal", and pg_trgm makes a misspelt county still match
  • Start-up refuses to run if either extension is missing
  • An administrator can rebuild the index from the admin with the plugin's reindex action
  • resolvePlace finds matching areas, then the recursive area query returns every seat above
    and below them and their current holders
  • /api/v1/search?q=&country= returns places with their representatives first, then actors,
    claims and topics
  • /{lang}/search renders the redesign's search results, linkable by address
  • Every search is logged with query, language, country and result count, and nothing about
    the person
  • A dashboard widget lists searches that found nothing
  • Test: searching the Kenyan fixture for "Nairobi" returns the president, the Nairobi
    governor, senator and woman representative, and every MP whose constituency is in Nairobi

Blocked by

Unblocks

Metadata

Metadata

Assignees

Labels

featureFeaturestatus: blockedWaits for the issues in its Blocked by sectiontrack: public sitePages, search, forms and sharingv3PromiseTracker v3

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions