Skip to content

[codex] Add occurrence row history#1195

Merged
karilint merged 1 commit into
mainfrom
codex/1192-occurrence-row-history
Jun 4, 2026
Merged

[codex] Add occurrence row history#1195
karilint merged 1 commit into
mainfrom
codex/1192-occurrence-row-history

Conversation

@karilint
Copy link
Copy Markdown
Collaborator

@karilint karilint commented Jun 3, 2026

Summary

  • Add batched backend enrichment for occurrence row history using the existing occurrence update merge logic.
  • Attach now_oau history arrays to now_ls rows in locality and species detail payloads.
  • Add occurrence row history icons to locality and species occurrence list tabs using the shared entry-history popover.
  • Extend frontend occurrence row types to allow optional now_oau on list rows.

Root Cause / Context

Occurrence rows are stored as now_ls relation records and their log rows can be associated with both locality update entries (luid) and species update entries (suid). The occurrence detail endpoint already knew how to merge those logs into now_oau, but the locality/species occurrence list rows did not receive that enriched history, so the row-level popover from #1191 had no complete occurrence history to show.

Validation

  • npm run tsc:backend
  • npm run tsc:frontend
  • cd frontend && npm test -- --runTestsByPath src/tests/components/DetailView/FieldUpdateHistory.test.tsx --runInBand
  • npm run lint:frontend
  • npm run lint:backend
  • Commit hook also ran root npm run lint and root npm run tsc successfully.

Closes #1192

@karilint karilint force-pushed the codex/1192-occurrence-row-history branch 2 times, most recently from 3a2e868 to f88f2a3 Compare June 4, 2026 11:35
@karilint karilint marked this pull request as ready for review June 4, 2026 11:42
@karilint karilint requested a review from Copilot June 4, 2026 11:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends “entry history” support to occurrence rows (now_ls) in locality/species occurrence lists by enriching list-row payloads with merged occurrence update history (previously only available on occurrence detail), then reusing the shared EntryUpdateHistory popover UI.

Changes:

  • Backend: add batched occurrence-history enrichment (getOccurrenceUpdatesForRows) and attach now_oau arrays onto now_ls rows in locality/species detail payloads.
  • Frontend: render an occurrence-row history icon/action in locality and species occurrence list tabs using EntryUpdateHistory.
  • Frontend: update history UI to group multiple logs per entry and deduplicate duplicate history entries; add/adjust tests and types to support optional now_oau on list rows.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/tests/components/DetailView/FieldUpdateHistory.test.tsx Expands tests to cover dedup/grouping for occurrence-row history popover content.
frontend/src/shared/types/data.ts Extends occurrence list row types to allow optional now_oau history arrays.
frontend/src/components/Species/Tabs/LocalitySpeciesTab.tsx Adds row-level history action for species → locality occurrence list rows.
frontend/src/components/Locality/Tabs/OccurrencesTab.tsx Adds row-level history action for locality → species occurrence list rows.
frontend/src/components/DetailView/common/FieldUpdateHistory.tsx Updates shared history popover to group logs and deduplicate duplicate history entries.
backend/src/services/species.ts Enriches species detail now_ls rows with merged occurrence history (now_oau).
backend/src/services/occurrenceService.ts Introduces batched getOccurrenceUpdatesForRows and reuses it for occurrence detail history.
backend/src/services/locality.ts Enriches locality detail now_ls rows with merged occurrence history (now_oau).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +74 to +79
oau_date: '2026-06-04',
oau_authorizer: 'ED',
oau_coordinator: 'CO',
oau_comment: 'Occurrence row changed',
now_or: [reference],
updates: [
Comment on lines +101 to +106
oau_date: '2026-06-04',
oau_authorizer: 'ED',
oau_coordinator: 'CO',
oau_comment: 'Occurrence row changed',
now_or: [reference],
updates: [
Comment on lines 188 to 194
const uniqueLidPks = Array.from(new Set(uniqueKeys.map(({ lid }) => `${lid.toString().length}.${lid};`)))
const candidateLogsRaw = await logDb.log.findMany({
where: {
table_name: 'now_ls',
pk_data: { contains: lidPk },
OR: uniqueLidPks.map(lidPk => ({ pk_data: { contains: lidPk } })),
},
})
@karilint karilint force-pushed the codex/1192-occurrence-row-history branch from f88f2a3 to 4394250 Compare June 4, 2026 12:20
@karilint karilint merged commit 1fed41d into main Jun 4, 2026
4 checks passed
@karilint karilint deleted the codex/1192-occurrence-row-history branch June 4, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Occurrence-row history for locality and species occurrence lists

2 participants