Skip to content

✨ feature: coordinators edit a Träger's about, machine-translated like opportunities (be#1407) - #1408

Merged
arturasmckwcz merged 2 commits into
developfrom
1407-organization-about-patch-translation
Nov 20, 2026
Merged

arturasmckwcz merged 2 commits into
developfrom
1407-organization-about-patch-translation

Conversation

@arturasmckwcz

@arturasmckwcz arturasmckwcz commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1407. This covers review findings #1 and #5 on #1406, plus machine translation of organization.about. Contract: need4deed-org/sdk#367 and need4deed-org/sdk#368 (need4deed-sdk 0.0.218).

PATCH /organization/:id

  • Accepts about. null or "" clears it. It is trimmed, and anything longer than ORGANIZATION_ABOUT_MAX_LENGTH (2000) gives 400.
  • The first time about is set, its language is detected (languageHint, else ?language=, else de) and stored in organization.original_language_id.
  • originalLanguage corrects a detected language, as on opportunities (setOriginalLanguage).
  • ?language=<lang> that isn't the original stores the text as a human translation and leaves the source unchanged (writeHumanTranslations, as divertTranslatedEdits does for opportunities). Clearing about is only allowed in the original language.
  • Each source change queues the other language for machine translation (enqueue). The existing worker picks it up with no change, since it works over every machine entry in the registry.

GET /organization/:id

  • ?language=<lang> serves the translated about once it's done and still matches the source. Otherwise it serves the original.
  • Returns originalLanguage.

Translation registry

  • organization → organizationId, field about, machine: true. The /translation review endpoints therefore also cover a Träger's about, and assertTranslationLength enforces the same 2000-character limit.

Migration organization-about-translation

Generated, with one addition by hand:

  • organization.original_language_id (FK → language, ON DELETE SET NULL).
  • field_translation.organization_id (FK, ON DELETE CASCADE) and the partial unique index UQ_field_translation_organization.
  • The comment, notion_relation, option and timeline entity-type enums gain organization, because sdk 0.0.218 adds it to EntityTableName.
  • Hand-written: CHK_field_translation_one_target is recreated to include organization_id. TypeORM doesn't diff a CHECK expression, so the generator leaves it out. down first deletes the Träger translation rows, then restores the old CHECK.

Checked locally: migration:generate --check reports no changes afterwards, and migration:revert followed by migration:run works on the test DB.

Tests

  • organization.routes.test.ts: detects German and English; queues the other language; stores an edit in the other language as a human translation and serves it in GET; clears with null or "" and drops the rows; gives 400 when clearing in a non-original language; gives 400 above the limit; corrects the original language and requeues.
  • registry.test.ts: organization is now a machine entry.

Self-review

  • Fixed: the row is locked before setOriginalLanguage; the language is detected again when about was empty (unless originalLanguage is sent with it); only an organization unique violation gives 409 for the title; the length error names the field; editLanguage, requestLanguage and languageIdOf moved to request-language.ts.
  • Not changed: no backfill is needed, because nothing could write about before this PR. down narrows the entity-type enums, so it would fail if a comment, timeline, option or notion_relation row used 'organization'. Nothing writes that value yet.

🤖 Generated with Claude Code

…e opportunities (be#1407)

- PATCH /organization/:id accepts about (null/"" clear it, max
  ORGANIZATION_ABOUT_MAX_LENGTH) and originalLanguage; ?language= edits in
  another language are stored as human translations.
- about is queued for machine translation; GET /organization/:id?language=
  serves the translation and returns originalLanguage.
- Migration: organization.original_language_id, field_translation.organization_id
  (FK, unique index, CHECK), and the entity-type enums gain 'organization'
  (sdk 0.0.218).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arturasmckwcz arturasmckwcz self-assigned this Nov 20, 2026
- Lock the organization before setOriginalLanguage, so it can't requeue a
  stale about.
- Detect the original language again when about was empty, unless the same
  request sends originalLanguage.
- Only a unique violation on organization itself is a taken title.
- Name the field in the length error.
- Move editLanguage, requestLanguage and languageIdOf to request-language.ts,
  out of the opportunity translation module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@nadavosa nadavosa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. Tested on a local merge with be#1410: migration runs clean on db-test, full suite 2675/2675.

`ALTER TYPE "public"."comment_entity_type_enum_old" RENAME TO "comment_entity_type_enum"`,
);
await queryRunner.query(
`CREATE INDEX "IDX_8c3af29493287693cdd82d99c1" ON "comment" ("entity_id", "entity_type", "language_id") `,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: down recreates the index as (entity_id, entity_type, language_id); the original is (entity_type, entity_id, language_id).

@need4deed need4deed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@arturasmckwcz
arturasmckwcz added this pull request to the merge queue Nov 20, 2026
Merged via the queue into develop with commit 0e926fb Nov 20, 2026
2 checks passed
@arturasmckwcz
arturasmckwcz deleted the 1407-organization-about-patch-translation branch November 20, 2026 17:58
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.

feat: coordinators edit a Träger's about via PATCH /organization/:id

3 participants