From 9d2bfd9d8f00f6fc5229d0174a220ba04dbc4ee8 Mon Sep 17 00:00:00 2001 From: Anurag Hazra Date: Thu, 19 May 2022 00:48:26 +0530 Subject: [PATCH] fix: temporarily increase the cache hours (#1771) --- api/index.js | 4 ++-- api/pin.js | 4 ++-- api/top-langs.js | 4 ++-- api/wakatime.js | 4 ++-- tests/api.test.js | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/api/index.js b/api/index.js index c983b43..6563dbc 100644 --- a/api/index.js +++ b/api/index.js @@ -52,8 +52,8 @@ module.exports = async (req, res) => { ); const cacheSeconds = clampValue( - parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10), - CONSTANTS.TWO_HOURS, + parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10), + CONSTANTS.FOUR_HOURS, CONSTANTS.ONE_DAY, ); diff --git a/api/pin.js b/api/pin.js index feffabd..f2761cb 100644 --- a/api/pin.js +++ b/api/pin.js @@ -41,8 +41,8 @@ module.exports = async (req, res) => { const repoData = await fetchRepo(username, repo); let cacheSeconds = clampValue( - parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10), - CONSTANTS.TWO_HOURS, + parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10), + CONSTANTS.FOUR_HOURS, CONSTANTS.ONE_DAY, ); diff --git a/api/top-langs.js b/api/top-langs.js index 32389c5..8080207 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -48,8 +48,8 @@ module.exports = async (req, res) => { ); const cacheSeconds = clampValue( - parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10), - CONSTANTS.TWO_HOURS, + parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10), + CONSTANTS.FOUR_HOURS, CONSTANTS.ONE_DAY, ); diff --git a/api/wakatime.js b/api/wakatime.js index d585c4a..18b5218 100644 --- a/api/wakatime.js +++ b/api/wakatime.js @@ -44,8 +44,8 @@ module.exports = async (req, res) => { const stats = await fetchWakatimeStats({ username, api_domain, range }); let cacheSeconds = clampValue( - parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10), - CONSTANTS.TWO_HOURS, + parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10), + CONSTANTS.FOUR_HOURS, CONSTANTS.ONE_DAY, ); diff --git a/tests/api.test.js b/tests/api.test.js index ffdf5e1..ef1f1fa 100644 --- a/tests/api.test.js +++ b/tests/api.test.js @@ -144,17 +144,17 @@ describe("Test /api/", () => { expect(res.setHeader.mock.calls).toEqual([ ["Content-Type", "image/svg+xml"], - ["Cache-Control", `public, max-age=${CONSTANTS.TWO_HOURS}`], + ["Cache-Control", `public, max-age=${CONSTANTS.FOUR_HOURS}`], ]); }); it("should set proper cache", async () => { - const { req, res } = faker({ cache_seconds: 8000 }, data); + const { req, res } = faker({ cache_seconds: 15000 }, data); await api(req, res); expect(res.setHeader.mock.calls).toEqual([ ["Content-Type", "image/svg+xml"], - ["Cache-Control", `public, max-age=${8000}`], + ["Cache-Control", `public, max-age=${15000}`], ]); }); @@ -176,7 +176,7 @@ describe("Test /api/", () => { expect(res.setHeader.mock.calls).toEqual([ ["Content-Type", "image/svg+xml"], - ["Cache-Control", `public, max-age=${CONSTANTS.TWO_HOURS}`], + ["Cache-Control", `public, max-age=${CONSTANTS.FOUR_HOURS}`], ]); } @@ -186,7 +186,7 @@ describe("Test /api/", () => { expect(res.setHeader.mock.calls).toEqual([ ["Content-Type", "image/svg+xml"], - ["Cache-Control", `public, max-age=${CONSTANTS.TWO_HOURS}`], + ["Cache-Control", `public, max-age=${CONSTANTS.FOUR_HOURS}`], ]); } });