Repository navigation
feat: add the credly template release queue and the badge template filter - #5166
Conversation
…lter Refs linuxfoundation/lfx-cdp-insights-ops#940 Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
PR SummaryMedium Risk Overview Credly client: Persistence: New DAL: Reviewed by Cursor Bugbot for commit 536b916. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🟡 Changes recommended
Transaction-stable now() leaves queuedAt unchanged on re-queue, allowing a stale release to overwrite the restarted cursor or incorrectly complete the new release.
1 open issue
What changed in this PR
Adds the foundations for replaying historical Credly badges after a template is mapped. The polling walk and resolve-script integration remain deferred to a follow-up PR.
Changes:
- Adds an optional badge-template filter to the Credly API client.
- Introduces a persistent release queue with cursor tracking and stale-walker guards.
- Adds tests for filtering, queue ordering, cursor persistence, re-queuing, and date bounds.
| File | Description |
|---|---|
services/libs/data-access-layer/src/credly/releases.ts |
Adds queue, cursor-save, and completion operations. |
services/libs/data-access-layer/src/credly/releases.test.ts |
Tests release queue behavior and validation. |
services/libs/connectors/src/connectors/credly/apiClient.ts |
Supports filtering badges by template ID. |
services/libs/connectors/src/connectors/credly/apiClient.test.ts |
Verifies the template filter alongside existing filters. |
backend/src/database/migrations/V1793617305__credly-template-releases.sql |
Creates the release table and pending-queue index. |
Review effort: Balanced
| ON CONFLICT ("badgeTemplateId") DO UPDATE | ||
| SET floor = EXCLUDED.floor, top = EXCLUDED.top, | ||
| since = NULL, until = NULL, page = 1, | ||
| "queuedAt" = now(), "completedAt" = NULL, "updatedAt" = now()`, |

Why
A template that leaves the held queue only gets the badges Credly changes from that moment on; everything before stays out. In prod today that is LFC131 (87k badges), the FinOps certifications, Kubestronaut and the KubeCon speaker badges, about 170k badges waiting on a mapping decision. Their history has to be re-read per template once they are mapped. This PR lays the foundations; the poll walk and the resolve script hook come in the next one.
What
badgeTemplateIdonfetchBadgesPage, sent asfilter[badge_template_id]inside thestate_updated_atwindow. Verified by hand on prod: LFC131 lists 250 badges for October against ~12k for the whole org.integration."credlyTemplateReleases": one row per template to re-read, withfloor,top, the open window cursor (since,until,page),queuedAtandcompletedAt. Partial index on the pending rows.queuedAtthey read, so a walk that was re-queued underneath gets 0 rows and stops.Testing
Refs linuxfoundation/lfx-cdp-insights-ops#940