fix: temporarily increase the cache hours (#1771)
This commit is contained in:
1 parent
9734a998cc
commit
9d2bfd9d8f
5 files changed
+13
-13
No files matched your search
+2
-2
@@ -52,8 +52,8 @@ module.exports = async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const cacheSeconds = clampValue(
|
const cacheSeconds = clampValue(
|
||||||
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
|
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||||
CONSTANTS.TWO_HOURS,
|
CONSTANTS.FOUR_HOURS,
|
||||||
CONSTANTS.ONE_DAY,
|
CONSTANTS.ONE_DAY,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -41,8 +41,8 @@ module.exports = async (req, res) => {
|
|||||||
const repoData = await fetchRepo(username, repo);
|
const repoData = await fetchRepo(username, repo);
|
||||||
|
|
||||||
let cacheSeconds = clampValue(
|
let cacheSeconds = clampValue(
|
||||||
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
|
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||||
CONSTANTS.TWO_HOURS,
|
CONSTANTS.FOUR_HOURS,
|
||||||
CONSTANTS.ONE_DAY,
|
CONSTANTS.ONE_DAY,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -48,8 +48,8 @@ module.exports = async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const cacheSeconds = clampValue(
|
const cacheSeconds = clampValue(
|
||||||
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
|
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||||
CONSTANTS.TWO_HOURS,
|
CONSTANTS.FOUR_HOURS,
|
||||||
CONSTANTS.ONE_DAY,
|
CONSTANTS.ONE_DAY,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -44,8 +44,8 @@ module.exports = async (req, res) => {
|
|||||||
const stats = await fetchWakatimeStats({ username, api_domain, range });
|
const stats = await fetchWakatimeStats({ username, api_domain, range });
|
||||||
|
|
||||||
let cacheSeconds = clampValue(
|
let cacheSeconds = clampValue(
|
||||||
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
|
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||||
CONSTANTS.TWO_HOURS,
|
CONSTANTS.FOUR_HOURS,
|
||||||
CONSTANTS.ONE_DAY,
|
CONSTANTS.ONE_DAY,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -144,17 +144,17 @@ describe("Test /api/", () => {
|
|||||||
|
|
||||||
expect(res.setHeader.mock.calls).toEqual([
|
expect(res.setHeader.mock.calls).toEqual([
|
||||||
["Content-Type", "image/svg+xml"],
|
["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 () => {
|
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);
|
await api(req, res);
|
||||||
|
|
||||||
expect(res.setHeader.mock.calls).toEqual([
|
expect(res.setHeader.mock.calls).toEqual([
|
||||||
["Content-Type", "image/svg+xml"],
|
["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([
|
expect(res.setHeader.mock.calls).toEqual([
|
||||||
["Content-Type", "image/svg+xml"],
|
["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([
|
expect(res.setHeader.mock.calls).toEqual([
|
||||||
["Content-Type", "image/svg+xml"],
|
["Content-Type", "image/svg+xml"],
|
||||||
["Cache-Control", `public, max-age=${CONSTANTS.TWO_HOURS}`],
|
["Cache-Control", `public, max-age=${CONSTANTS.FOUR_HOURS}`],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user