chore: minor changes in pat info (#2481)

This commit is contained in:
Anurag Hazra 2023-01-28 20:32:40 +05:30 committed by GitHub
parent 077d40561a
commit 7aa502d453
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View file

@ -6,7 +6,7 @@
*/
import { logger, request, dateDiff } from "../../src/common/utils.js";
export const RATE_LIMIT_SECONDS = 60 * 10; // 1 request per 10 minutes
export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 10 minutes
/**
* Simple uptime check fetcher for the PATs.
@ -98,12 +98,20 @@ const getPATInfo = async (fetcher, variables) => {
return Object.keys(details).filter((pat) => details[pat].status === status);
};
const sortedDetails = Object.keys(details)
.sort()
.reduce((obj, key) => {
obj[key] = details[key];
return obj;
}, {});
return {
validPATs: filterPATsByStatus("valid"),
expiredPATs: filterPATsByStatus("expired"),
exhaustedPATS: filterPATsByStatus("exhausted"),
exhaustedPATs: filterPATsByStatus("exhausted"),
suspendedPATs: filterPATsByStatus("suspended"),
errorPATs: filterPATsByStatus("error"),
details,
details: sortedDetails,
};
};

View file

@ -88,7 +88,8 @@ describe("Test /api/status/pat-info", () => {
{
validPATs: ["PAT_2", "PAT_3", "PAT_4"],
expiredPATs: [],
exhaustedPATS: ["PAT_1"],
exhaustedPATs: ["PAT_1"],
suspendedPATs: [],
errorPATs: [],
details: {
PAT_1: {
@ -132,7 +133,8 @@ describe("Test /api/status/pat-info", () => {
{
validPATs: ["PAT_2", "PAT_3", "PAT_4"],
expiredPATs: [],
exhaustedPATS: [],
exhaustedPATs: [],
suspendedPATs: [],
errorPATs: ["PAT_1"],
details: {
PAT_1: {
@ -178,7 +180,8 @@ describe("Test /api/status/pat-info", () => {
{
validPATs: ["PAT_2", "PAT_3", "PAT_4"],
expiredPATs: ["PAT_1"],
exhaustedPATS: [],
exhaustedPATs: [],
suspendedPATs: [],
errorPATs: [],
details: {
PAT_1: {