Skip to content

[O2B-1620] Tags should associate user by id and not direct name - #2234

Open
graduta wants to merge 5 commits into
mainfrom
feature/O2B-1620/associate-user-tag-by-id-not-name
Open

graduta wants to merge 5 commits into
mainfrom
feature/O2B-1620/associate-user-tag-by-id-not-name

Conversation

@graduta

@graduta graduta commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

I have a JIRA ticket

  • branch and/or PR name(s) include(s) JIRA ID
  • issue has "Fix version" assigned
  • issue "Status" is set to "In review"
  • PR labels are selected

Notable changes for users:

  • none

Notable changes for developers:

  • tags endpoint are now returning an object with user name (only) that last edited with name only rather than entire entity
  • the TagUseCase has been updated to not be aware of HTTP return status code and instead throw when a critical condition is not met. This in turn makes it easier to transition towards the recommended BKP architecture of high/low level service
  • front-end changes are minimal to update the new structure of returned object
  • purpose of the ticket is to make pseduoanonymisation easier to achieve

Changes made to the database:

  • tags table now store the association with user table by ID and not name of user

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.22%. Comparing base (f9c05ae) to head (4bd7b9b).

Files with missing lines Patch % Lines
...s/v1/20260930100000-tags-last-edited-by-user-id.js 55.55% 4 Missing ⚠️
lib/public/components/tag/tagDetail.js 0.00% 1 Missing ⚠️
...blic/views/Tags/ActiveColumns/tagsActiveColumns.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2234      +/-   ##
==========================================
+ Coverage   46.17%   46.22%   +0.05%     
==========================================
  Files        1040     1041       +1     
  Lines       17160    17178      +18     
  Branches     3133     3129       -4     
==========================================
+ Hits         7923     7941      +18     
  Misses       9237     9237              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@graduta
graduta added this pull request to stack #2236 October 1, 2026 14:55
@graduta graduta changed the title [O2B-1620] Tags should associate user by id and not name on update [O2B-1620] Tags should associate user by id and not direct name Oct 2, 2026
Comment thread docs/data-model.md
| `Mattermost` | Mattermost channels | `Food`, `Bookkeeping updates` | | `id` | Update |
| `email` | Email groups | `food@cern.ch`, `Bookkeeping-updates@cern.ch` | | `id` | Update |
| `last_edited_name` | Name of the person who last edited the email/mattermost fields | `Anonymous`, `Jan Janssen` | When email/mattermost is edited | `id` | Update |
| `last_edited_by_user_id` | Id (in `users` table) of the user who last edited the tag | `1`, `2` | When the tag is edited | `id` | Update |

@isaachilly isaachilly Oct 2, 2026 •

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.

'When the tag is edited' reads as if the field is only set when the tag is updated. After this change it's also set when the tag is created. Do you think it could be more specific, or is it clear enough?

text,
description,
lastEditedName: last_edited_name,
lastEditedBy: lastEditedBy ? this.userAdapter.toNameOnly(lastEditedBy) : null,

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.

RunAdapter, LogAdapter and LogService all call tagAdapter.toEntity without the association, so their lastEditedBy is always null. I think we should either include the association or omit the field, what do you think?

return TagRepository.insert(tagAdapter.toDatabase(body));
});

return tag ? tagAdapter.toEntity(tag) : null;

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.

CreateTagUseCase returns lastEditedBy as null in the create response. UpdateTagUseCase solves this by re-fetching the tag.

Could it be worth avoiding confusion/inconsistency to do the same?


expect(result.lastEditedBy).to.deep.equal({ name: 'Jan Jansen' });

await TagRepository.removeAll(new QueryBuilder().where('id').is(createdTag.id));

@isaachilly isaachilly Oct 2, 2026 •

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.

In both new tests, if the assertion fails, the removeAll never gets run and the inserted tag remains in the DB. Could the cleanup go in a finally or an afterEach?

@isaachilly isaachilly 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.

There are a couple of API changes here: tag creation requiring a session user and lastEditedName being replaced by lastEditedBy. Worth double-checking if you haven't already that these aren't critically relied upon, esepcially in the emails by tags system. Should be clearly mentioned in release notes anyways.

I ran the migration against a local prod dump and every name mapped to a user. Since unmapped names will get lost, it might be worth checking on actual prod for peace of mind that this is also the case.

Other than that and the inline comments, looks good to me.

This branch has not been deployed

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

Development

Successfully merging this pull request may close these issues.

2 participants