feat(records): «Запланировано» badge per row для scheduled future versions

Last item из QA report backlog'а. Banner + empty-state hint показывают
aggregate count, но не помогают find конкретные записи которые скоро
изменятся. Badge per row даёт O(1) visual scan.

Backend (read-api):
- ScheduledRecordsSummary.scheduledBusinessKeys: List<String> (capped 500)
- Repo method findScheduledBusinessKeys (DISTINCT subquery)
- Single fetch вместо N+1 per-row queries

Frontend:
- scheduledByKey Set<string> построен из summary
- Badge variant=info «Запланировано» рядом с businessKey badge'ом
- Title attribute с full RU/EN tooltip
- Не блокирует layout — gap-1.5 с pendingReview badge'ем (могут быть оба)

i18n keys для ru/en — short label «Запланировано» / «Scheduled».
This commit is contained in:
Zimin A.N.
2026-05-16 12:49:42 +03:00
parent dbbefe0510
commit e5a07fc391
6 changed files with 74 additions and 3 deletions
@@ -228,4 +228,28 @@ public interface DictionaryRecordRepository extends JpaRepository<DictionaryReco
@Param("allowedScopes") Collection<DataScope> allowedScopes,
@Param("now") OffsetDateTime now,
org.springframework.data.domain.Pageable pageable);
/**
* Distinct businessKeys которые имеют scheduled future version
* (validFrom > now, validTo > now). Frontend mapping → render «Scheduled»
* badge per row в records table.
*
* <p>Один из ключей может появиться несколько раз если у dict'а есть
* несколько future versions того же businessKey — DISTINCT убирает дубли.
*
* <p>Capped на 500 keys в service слое — больше типичный admin не fetch'ит
* за раз (если scheduled > 500, banner показывает общий count).
*/
@Query("""
SELECT DISTINCT r.businessKey FROM DictionaryRecord r
WHERE r.dictionaryId = :dictionaryId
AND r.dataScope IN :allowedScopes
AND r.validFrom > :now
AND r.validTo > :now
""")
List<String> findScheduledBusinessKeys(
@Param("dictionaryId") UUID dictionaryId,
@Param("allowedScopes") Collection<DataScope> allowedScopes,
@Param("now") OffsetDateTime now,
org.springframework.data.domain.Pageable pageable);
}