diff --git a/.github/workflows/repeat-recent-requests.yml b/.github/workflows/repeat-recent-requests.yml index 1ac88e50..dba0bc5d 100644 --- a/.github/workflows/repeat-recent-requests.yml +++ b/.github/workflows/repeat-recent-requests.yml @@ -10,7 +10,7 @@ on: # │ │ │ │ │ # │ │ │ │ │ # * * * * * - - cron: "45 1/12 * * *" + - cron: "45 1/6 * * *" workflow_dispatch: jobs: diff --git a/_dot_vercel_copy/output/functions/api.prerender-config.json b/_dot_vercel_copy/output/functions/api.prerender-config.json index bea81b9c..d7747ff4 100644 --- a/_dot_vercel_copy/output/functions/api.prerender-config.json +++ b/_dot_vercel_copy/output/functions/api.prerender-config.json @@ -1,5 +1,5 @@ { - "expiration": 5, + "expiration": 39600, "bypassToken": "r3fr3shT0k3n-r3fr3shT0k3n-r3fr3shT0k3n", "passQuery": true } \ No newline at end of file diff --git a/_dot_vercel_copy/output/functions/api/gist.prerender-config.json b/_dot_vercel_copy/output/functions/api/gist.prerender-config.json index bea81b9c..d7747ff4 100644 --- a/_dot_vercel_copy/output/functions/api/gist.prerender-config.json +++ b/_dot_vercel_copy/output/functions/api/gist.prerender-config.json @@ -1,5 +1,5 @@ { - "expiration": 5, + "expiration": 39600, "bypassToken": "r3fr3shT0k3n-r3fr3shT0k3n-r3fr3shT0k3n", "passQuery": true } \ No newline at end of file diff --git a/_dot_vercel_copy/output/functions/api/pin.prerender-config.json b/_dot_vercel_copy/output/functions/api/pin.prerender-config.json index bea81b9c..d7747ff4 100644 --- a/_dot_vercel_copy/output/functions/api/pin.prerender-config.json +++ b/_dot_vercel_copy/output/functions/api/pin.prerender-config.json @@ -1,5 +1,5 @@ { - "expiration": 5, + "expiration": 39600, "bypassToken": "r3fr3shT0k3n-r3fr3shT0k3n-r3fr3shT0k3n", "passQuery": true } \ No newline at end of file diff --git a/_dot_vercel_copy/output/functions/api/top-langs.prerender-config.json b/_dot_vercel_copy/output/functions/api/top-langs.prerender-config.json index bea81b9c..d7747ff4 100644 --- a/_dot_vercel_copy/output/functions/api/top-langs.prerender-config.json +++ b/_dot_vercel_copy/output/functions/api/top-langs.prerender-config.json @@ -1,5 +1,5 @@ { - "expiration": 5, + "expiration": 39600, "bypassToken": "r3fr3shT0k3n-r3fr3shT0k3n-r3fr3shT0k3n", "passQuery": true } \ No newline at end of file diff --git a/_dot_vercel_copy/output/functions/api/wakatime.prerender-config.json b/_dot_vercel_copy/output/functions/api/wakatime.prerender-config.json index bea81b9c..d7747ff4 100644 --- a/_dot_vercel_copy/output/functions/api/wakatime.prerender-config.json +++ b/_dot_vercel_copy/output/functions/api/wakatime.prerender-config.json @@ -1,5 +1,5 @@ { - "expiration": 5, + "expiration": 39600, "bypassToken": "r3fr3shT0k3n-r3fr3shT0k3n-r3fr3shT0k3n", "passQuery": true } \ No newline at end of file diff --git a/api-renamed/gist.js b/api-renamed/gist.js index e72cd304..0ef3b7f8 100644 --- a/api-renamed/gist.js +++ b/api-renamed/gist.js @@ -44,8 +44,8 @@ export default async (req, res) => { const gistData = await fetchGist(id); let cacheSeconds = clampValue( - parseInt(cache_seconds || CONSTANTS.TWO_DAY, 10), - CONSTANTS.TWO_DAY, + parseInt(cache_seconds || CONSTANTS.EIGHT_HOURS, 10), + CONSTANTS.FOUR_HOURS, CONSTANTS.SIX_DAY, ); cacheSeconds = process.env.CACHE_SECONDS diff --git a/api-renamed/index.js b/api-renamed/index.js index ad96d594..098dfa5b 100644 --- a/api-renamed/index.js +++ b/api-renamed/index.js @@ -117,7 +117,7 @@ export default async (req, res) => { let cacheSeconds = clampValue( parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10), - CONSTANTS.TWELVE_HOURS, + CONSTANTS.FOUR_HOURS, CONSTANTS.TWO_DAY, ); cacheSeconds = process.env.CACHE_SECONDS diff --git a/api-renamed/pin.js b/api-renamed/pin.js index c143b80f..4ac56bcc 100644 --- a/api-renamed/pin.js +++ b/api-renamed/pin.js @@ -96,7 +96,7 @@ export default async (req, res) => { let cacheSeconds = clampValue( parseInt(cache_seconds || CONSTANTS.PIN_CARD_CACHE_SECONDS, 10), - CONSTANTS.ONE_DAY, + CONSTANTS.FOUR_HOURS, CONSTANTS.TEN_DAY, ); cacheSeconds = process.env.CACHE_SECONDS diff --git a/api-renamed/status/pat-info.js b/api-renamed/status/pat-info.js index 1f17bf65..8b15d76b 100644 --- a/api-renamed/status/pat-info.js +++ b/api-renamed/status/pat-info.js @@ -2,11 +2,11 @@ * @file Contains a simple cloud function that can be used to check which PATs are no * longer working. It returns a list of valid PATs, expired PATs and PATs with errors. * - * @description This function is currently rate limited to 1 request per 5 minutes. + * @description This function is currently rate limited to 1 request per 3 minutes. */ import { logger, request, dateDiff } from "../../src/common/utils.js"; -export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 5 minutes +export const RATE_LIMIT_SECONDS = 60 * 3; // 1 request per 3 minutes /** * @typedef {import('axios').AxiosRequestHeaders} AxiosRequestHeaders Axios request headers. diff --git a/api-renamed/status/up.js b/api-renamed/status/up.js index 6ed7c37c..168930b7 100644 --- a/api-renamed/status/up.js +++ b/api-renamed/status/up.js @@ -2,13 +2,13 @@ * @file Contains a simple cloud function that can be used to check if the PATs are still * functional. * - * @description This function is currently rate limited to 1 request per 5 minutes. + * @description This function is currently rate limited to 1 request per 3 minutes. */ import retryer from "../../src/common/retryer.js"; import { logger, request } from "../../src/common/utils.js"; -export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 5 minutes +export const RATE_LIMIT_SECONDS = 60 * 3; // 1 request per 3 minutes /** * @typedef {import('axios').AxiosRequestHeaders} AxiosRequestHeaders Axios request headers. diff --git a/api-renamed/wakatime.js b/api-renamed/wakatime.js index b63cfe51..196892d2 100644 --- a/api-renamed/wakatime.js +++ b/api-renamed/wakatime.js @@ -55,7 +55,7 @@ export default async (req, res) => { let cacheSeconds = clampValue( parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10), - CONSTANTS.SIX_HOURS, + CONSTANTS.FOUR_HOURS, CONSTANTS.TWO_DAY, ); cacheSeconds = process.env.CACHE_SECONDS diff --git a/src/common/database.js b/src/common/database.js index 31850148..eca07cd0 100644 --- a/src/common/database.js +++ b/src/common/database.js @@ -53,7 +53,7 @@ export async function storeRequest(req) { } /** - * Deletes all requests older than 7 days from the database. + * Deletes all requests older than 8 days from the database. */ async function deleteOldRequests() { if (!pool) { @@ -62,15 +62,15 @@ async function deleteOldRequests() { const deleteQuery = ` DELETE FROM requests - WHERE user_requested_at < NOW() - INTERVAL '7 days' + WHERE user_requested_at < NOW() - INTERVAL '8 days' `; const result = await pool.query(deleteQuery); console.log(`Deleted ${result.rowCount} old requests.`); } /** - * Fetches all requests from the last 7 days. - * @returns {Promise} An array of requests made in the last 7 days. + * Fetches all requests which are between 11 hours and 8 days old. + * @returns {Promise} Array of all requests between 11 hours and 8 days old. */ async function getRecentRequests() { if (!pool) { @@ -80,8 +80,8 @@ async function getRecentRequests() { const query = ` SELECT request FROM requests - WHERE requested_at >= NOW() - INTERVAL '7 days' - AND requested_at < NOW() - INTERVAL '1 hour' + WHERE requested_at >= NOW() - INTERVAL '8 days' + AND requested_at < NOW() - INTERVAL '11 hours' ORDER BY requested_at ASC `; const { rows } = await pool.query(query); @@ -129,7 +129,7 @@ async function makeRequests(urls, poolSize) { } /** - * Repeats requests made in the last 7 days, excluding those made in the last hour. + * Repeats requests made in the last 8 days, excluding those made in the last 11 hours. */ export async function repeatRecentRequests() { if (!pool) { diff --git a/src/common/utils.js b/src/common/utils.js index 81ebbfcc..b79c38a8 100644 --- a/src/common/utils.js +++ b/src/common/utils.js @@ -482,9 +482,9 @@ const CONSTANTS = { TWO_DAY, SIX_DAY, TEN_DAY, - CARD_CACHE_SECONDS: ONE_DAY, - TOP_LANGS_CACHE_SECONDS: SIX_DAY, - PIN_CARD_CACHE_SECONDS: TEN_DAY, + CARD_CACHE_SECONDS: EIGHT_HOURS, + TOP_LANGS_CACHE_SECONDS: EIGHT_HOURS, + PIN_CARD_CACHE_SECONDS: EIGHT_HOURS, ERROR_CACHE_SECONDS: TEN_MINUTES, };