Skip to content

Commit fe88ea1

Browse files
Merge branch 'staging'
2 parents d5e1092 + e43fcd6 commit fe88ea1

4 files changed

Lines changed: 100 additions & 4 deletions

File tree

apps/backend/routes/auth/getAuditSummary.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface ItemCount {
4040
}
4141

4242
export const getAuditSummary = async () => {
43+
const start = performance.now();
4344
const auditId = (event.queryStringParameters as any).id;
4445
const mostCommonUrlsLimit =
4546
(event.queryStringParameters as any).mostCommonUrlsLimit ?? 5;
@@ -74,7 +75,7 @@ export const getAuditSummary = async () => {
7475
},
7576
};
7677
const response = (await graphqlQuery(query)) as AuditSummaryResp;
77-
console.log(JSON.stringify({ response }));
78+
//console.log(JSON.stringify({ response }));
7879

7980
const flattened = response.blockers.map((item) => {
8081
return {
@@ -117,6 +118,8 @@ export const getAuditSummary = async () => {
117118
mostCommonTagsLimit
118119
)
119120

121+
const end = performance.now();
122+
120123
return {
121124
statusCode: 200,
122125
headers: { "content-type": "application/json" },
@@ -125,7 +128,8 @@ export const getAuditSummary = async () => {
125128
urlsWithMostErrors,
126129
mostCommonErrors,
127130
mostCommonCategory,
128-
mostCommonTags
131+
mostCommonTags,
132+
executionTime: end - start
129133
},
130134
};
131135
};
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import { db, event, graphqlQuery } from "#src/utils";
2+
3+
interface ItemCount {
4+
key: string;
5+
count: number;
6+
}
7+
8+
interface AuditSummaryResp {
9+
unique_url_stats: {
10+
aggregate: {
11+
count: number;
12+
};
13+
};
14+
mostCommonUrls: ItemCount[];
15+
mostCommonBlockers: ItemCount[];
16+
mostCommonTags: ItemCount[];
17+
}
18+
19+
export const getAuditSummaryFast = async () => {
20+
21+
const start = performance.now();
22+
const auditId = (event.queryStringParameters as any).id;
23+
const mostCommonUrlsLimit =
24+
(event.queryStringParameters as any).mostCommonUrlsLimit ?? 5;
25+
const mostCommonBlockersLimit =
26+
(event.queryStringParameters as any).mostCommonBlockersLimit ?? 5;
27+
/* const mostCommonCategoriesLimit =
28+
(event.queryStringParameters as any).mostCommonCategoriesLimit ?? 3;
29+
*/
30+
const mostCommonTagsLimit =
31+
(event.queryStringParameters as any).mostCommonTagsLimit ?? 3;
32+
33+
const query = {
34+
query: `query GetFullAuditSummary(
35+
$audit_id: uuid!,
36+
$urlLimit: Int,
37+
$msgLimit: Int,
38+
$tagLimit: Int
39+
) {
40+
# 1. Total Unique URLs with blockers
41+
unique_url_stats: blocker_summary_view_aggregate(
42+
where: { audit_id: { _eq: $audit_id } }
43+
) {
44+
aggregate {
45+
count(columns: url, distinct: true)
46+
}
47+
}
48+
49+
mostCommonUrls: get_most_common_urls(
50+
args: { search_audit_id: $audit_id, row_limit: $urlLimit }
51+
) {
52+
key
53+
count
54+
}
55+
56+
mostCommonBlockers: get_most_common_messages(
57+
args: { search_audit_id: $audit_id, row_limit: $msgLimit }
58+
) {
59+
key
60+
count
61+
}
62+
63+
mostCommonTags: get_most_common_tags(
64+
args: { search_audit_id: $audit_id, row_limit: $tagLimit }
65+
) {
66+
key
67+
count
68+
}
69+
}`,
70+
variables: {
71+
audit_id: auditId,
72+
urlLimit: mostCommonUrlsLimit,
73+
msgLimit: mostCommonBlockersLimit,
74+
tagLimit: mostCommonTagsLimit
75+
},
76+
};
77+
const response = (await graphqlQuery(query)) as AuditSummaryResp;
78+
79+
const end = performance.now();
80+
return {
81+
statusCode: 200,
82+
headers: { "content-type": "application/json" },
83+
body: {
84+
urlsWithBlockersCount: response.unique_url_stats.aggregate.count,
85+
urlsWithMostErrors: response.mostCommonUrls,
86+
mostCommonErrors: response.mostCommonBlockers,
87+
mostCommonTags: response.mostCommonTags,
88+
executionTime: end - start
89+
},
90+
};
91+
};

apps/backend/routes/auth/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from './getAuditTable'
1414
export * from './getLogs'
1515
export * from './inviteUser'
1616
export * from './getAuditSummary'
17+
export * from './getAuditSummaryFast'
1718
export * from './saveQuickScan'
1819
export * from './getQuickScans'
1920
export * from './fetchRemoteCsv'

apps/frontend/src/components/BlockersTableSummary.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ export const BlockersTableSummary = ({ auditId, isShared, chartData, pages, scan
5353
};
5454
const response = await API.get({
5555
apiName: isShared ? "public" : "auth",
56-
path: "/getAuditSummary",
56+
path: "/getAuditSummaryFast",
5757
options: { queryParams: params },
5858
}).response;
5959
const resp = (await response.body.json()) as any as SummaryResp;
60-
//console.log(resp);
60+
console.log(resp);
6161
return resp;
6262
}
6363
});

0 commit comments

Comments
 (0)