mirror of
https://github.com/ever-co/ever-gauzy.git
synced 2026-10-02 01:54:50 +08:00
* fix(tags): count tag usages with COUNT(DISTINCT) and fill tagTypeName on MikroORM
TagService.findTags LEFT JOINs all 25 tagged relations (plus many-to-many
custom fields) in one query and counted each with COUNT(...). The joins
multiply rows, so every counter was multiplied by the matches of the other
relations: a tag on 2 employees and 3 tasks reported 6 + 6 = 12 usages on
the Tags page instead of 5. Use COUNT(DISTINCT ...) for every counter.
The MikroORM branch also never set `tagTypeName`, which the Tags page shows
in its Type column ("—" for every tag). Set it from the populated tagType.
The MikroORM branch still returns no *_counter fields (usage shows 0);
that needs an aggregate query of its own.
* refactor(tags): build the usage joins and counters from one table; always load tagType
- Drive the 25 relation LEFT JOINs and COUNT(DISTINCT) counters from an
exported TAG_USAGE_COUNTERS table instead of 50 near-identical lines
(Sonar duplication on new code).
- MikroORM: always populate tagType so tagTypeName is set even when the
caller requests no relations.
- Spec: assert each relation is joined and counted under its expected
counter (and nothing else), plus a many-to-many custom field.
* test(tags): cover tagType loading and tagTypeName on the MikroORM branch