Skip to content

Commit 7aa502d

Browse files
authored
chore: minor changes in pat info (#2481)
1 parent 077d405 commit 7aa502d

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

api/status/pat-info.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { logger, request, dateDiff } from "../../src/common/utils.js";
9-
export const RATE_LIMIT_SECONDS = 60 * 10; // 1 request per 10 minutes
9+
export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 10 minutes
1010

1111
/**
1212
* Simple uptime check fetcher for the PATs.
@@ -98,12 +98,20 @@ const getPATInfo = async (fetcher, variables) => {
9898
return Object.keys(details).filter((pat) => details[pat].status === status);
9999
};
100100

101+
const sortedDetails = Object.keys(details)
102+
.sort()
103+
.reduce((obj, key) => {
104+
obj[key] = details[key];
105+
return obj;
106+
}, {});
107+
101108
return {
102109
validPATs: filterPATsByStatus("valid"),
103110
expiredPATs: filterPATsByStatus("expired"),
104-
exhaustedPATS: filterPATsByStatus("exhausted"),
111+
exhaustedPATs: filterPATsByStatus("exhausted"),
112+
suspendedPATs: filterPATsByStatus("suspended"),
105113
errorPATs: filterPATsByStatus("error"),
106-
details,
114+
details: sortedDetails,
107115
};
108116
};
109117

tests/pat-info.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ describe("Test /api/status/pat-info", () => {
8888
{
8989
validPATs: ["PAT_2", "PAT_3", "PAT_4"],
9090
expiredPATs: [],
91-
exhaustedPATS: ["PAT_1"],
91+
exhaustedPATs: ["PAT_1"],
92+
suspendedPATs: [],
9293
errorPATs: [],
9394
details: {
9495
PAT_1: {
@@ -132,7 +133,8 @@ describe("Test /api/status/pat-info", () => {
132133
{
133134
validPATs: ["PAT_2", "PAT_3", "PAT_4"],
134135
expiredPATs: [],
135-
exhaustedPATS: [],
136+
exhaustedPATs: [],
137+
suspendedPATs: [],
136138
errorPATs: ["PAT_1"],
137139
details: {
138140
PAT_1: {
@@ -178,7 +180,8 @@ describe("Test /api/status/pat-info", () => {
178180
{
179181
validPATs: ["PAT_2", "PAT_3", "PAT_4"],
180182
expiredPATs: ["PAT_1"],
181-
exhaustedPATS: [],
183+
exhaustedPATs: [],
184+
suspendedPATs: [],
182185
errorPATs: [],
183186
details: {
184187
PAT_1: {

0 commit comments

Comments
 (0)