Skip to content

Drop the profile-number discovery dance once v2 create returns the profile #836

Description

@hokiepokedad2

Blocked on jfberry/PoracleNG#217.

ProfileNumbering.ResolveCreated exists because v1's POST /api/profiles/{id}/add answers {"status":"ok"} and withholds the number it just assigned. PoracleNG allocates the lowest free profile number, not max + 1 — with 0, 1, 3 taken the new profile lands at 2 — so the number can't be predicted and has to be discovered by snapshotting the list, creating, re-reading and diffing. Diffing rather than matching on name, because profile names aren't unique. See #407 for what predicting max + 1 did: alarms copied to a profile_no with no profile row, which later adopted whatever profile was eventually created there.

#217 makes the v2 create return the created profile.

Delete

Four call sites, each doing the same snapshot/create/re-read/diff:

  • ProfileController.CreateProfileController.cs:170
  • ProfileController.DuplicateProfileController.cs:322
  • ProfileOverviewController.DuplicateProfileProfileOverviewController.cs:74
  • ProfileOverviewController.ImportProfileProfileOverviewController.cs:169

Then Core.Models/Helpers/ProfileNumbering.cs and its tests.

Watch for

The v1 path has to survive. ProfileNumbering goes only when the create actually ran through v2 — a server without the route still needs the diff. Either keep the helper behind the same capability check the rest of the v2 write path uses, or accept a hard 5.2.2 minimum and say so in the release notes.

Update the "Profile Numbering and Rename" section of CLAUDE.md in the same change — it documents this workaround as current.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions