Skip to content

Commit 262fedd

Browse files
authored
fix: update remaining count key (#1737)
* fix: update remaining count key * update tests
1 parent ae22c79 commit 262fedd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

controllers/cloudflareCache.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ const fetchPurgedCacheMetadata = async (req, res) => {
8181
const { timestamp } = latestCacheMetadata;
8282
return res.json({
8383
message: "Purged cache metadata returned successfully!",
84-
count: logs.length,
84+
remainingCount: MAX_CACHE_PURGE_COUNT - logs.length,
8585
timeLastCleared: timestamp._seconds,
8686
});
8787
} else if ((await logsQuery.fetchLastAddedCacheLog(id)).length !== 0) {
8888
const lastLog = await logsQuery.fetchLastAddedCacheLog(id);
8989
const { timestamp } = lastLog[0];
9090
return res.json({
9191
message: "Purged cache metadata returned successfully!",
92-
count: 0,
92+
remainingCount: MAX_CACHE_PURGE_COUNT,
9393
timeLastCleared: timestamp._seconds,
9494
});
9595
} else {
9696
return res.json({
9797
message: "No cache is cleared yet",
98-
count: 0,
98+
remainingCount: MAX_CACHE_PURGE_COUNT,
9999
});
100100
}
101101
} catch (error) {

test/integration/cloudflareCache.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe("Purged Cache Metadata", function () {
4848
expect(response).to.have.status(200);
4949
expect(response.body).to.be.an("object");
5050
expect(response.body.message).to.equal("No cache is cleared yet");
51-
expect(response.body.count).to.equal(0);
51+
expect(response.body.remainingCount).to.equal(3);
5252
return done();
5353
});
5454
});
@@ -67,7 +67,7 @@ describe("Purged Cache Metadata", function () {
6767
expect(response).to.have.status(200);
6868
expect(response.body).to.be.an("object");
6969
expect(response.body.message).to.equal("Purged cache metadata returned successfully!");
70-
expect(response.body.count).to.be.a("number");
70+
expect(response.body.remainingCount).to.be.a("number");
7171
expect(response.body.timeLastCleared).to.be.a("number");
7272

7373
return done();

0 commit comments

Comments
 (0)