From 8479a0be3fb631116e6cb3a8ee5857fc085fc89f Mon Sep 17 00:00:00 2001 From: zcmander Date: Thu, 25 Apr 2024 14:11:18 +0300 Subject: [PATCH] fix: stitching queue gauge to not include entities from the future Signed-off-by: zcmander --- .changeset/sweet-zoos-clap.md | 5 +++++ plugins/catalog-backend/src/stitching/progressTracker.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/sweet-zoos-clap.md diff --git a/.changeset/sweet-zoos-clap.md b/.changeset/sweet-zoos-clap.md new file mode 100644 index 0000000000..8c76f4abd7 --- /dev/null +++ b/.changeset/sweet-zoos-clap.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Fixed bug in stitching queue gauge that included entities that are scheduled in the future. diff --git a/plugins/catalog-backend/src/stitching/progressTracker.ts b/plugins/catalog-backend/src/stitching/progressTracker.ts index 9e00a1a01b..8c305b4978 100644 --- a/plugins/catalog-backend/src/stitching/progressTracker.ts +++ b/plugins/catalog-backend/src/stitching/progressTracker.ts @@ -54,7 +54,8 @@ export function progressTracker(knex: Knex, logger: LoggerService) { stitchingQueueCount.addCallback(async result => { const total = await knex('refresh_state') .count({ count: '*' }) - .whereNotNull('next_stitch_at'); + .whereNotNull('next_stitch_at') + .where('next_stitch_at', '<=', knex.fn.now()); result.observe(Number(total[0].count)); });