code format & renaming

This commit is contained in:
JOLIMAITRE Matthieu 2024-04-15 10:19:38 +02:00
parent c1935fb360
commit 90a7af344e
2 changed files with 9 additions and 8 deletions

View file

@ -13,6 +13,7 @@ async function hash(namespace: string) {
const relevant_hash = "Qa4xy8yRPnBsQf8U2UUE7tse2u4Fi/Aqxbt" +
"6aq56m5ofcmCkTi8PbgMBF1OtHC6qkXDF2tz2qKprYCIAMzTSQQ==";
Deno.test("encode_namespace", async () => {
const namespace = "CHANGEME";
const base64 = await hash(namespace);

View file

@ -12,7 +12,7 @@ async function main() {
if (token === undefined) token = prompt_args();
const client = new ApiClient("gitlab.cri.epita.fr", token);
const merge_requests = await get_all_merge_requests(client);
const total = sum(await parallel(merge_requests, (mr) => count_in_mr(mr, client)));
const total = sum(await parallel(merge_requests, (mr) => count_in_merge_request(mr, client)));
console.log("Total", total, "oki");
}
@ -35,17 +35,17 @@ ${gr("> xxxxxxxxxxxxxxxxxxxx")}
return result.trim();
}
async function get_all_merge_requests(client: ApiClient): Promise<MergeRequest[]> {
async function get_all_merge_requests(client: ApiClient) {
return await client.fetch_parse_paginated(`api/v4/merge_requests`, merge_request_parser);
}
async function count_in_mr(mr: MergeRequest, client: ApiClient) {
async function count_in_merge_request(merge_request: MergeRequest, client: ApiClient) {
let total = 0;
const mr_path = `api/v4/projects/${mr.project_id}/merge_requests/${mr.iid}`;
const all_notes = await client.fetch_parse_paginated(`${mr_path}/notes`, note_parser);
for (const c of all_notes) {
if (!await is_relevant(c.author.username)) continue;
if (c.body.toLowerCase().includes("oki")) total += 1;
const merge_request_path = `api/v4/projects/${merge_request.project_id}/merge_requests/${merge_request.iid}`;
const all_notes = await client.fetch_parse_paginated(`${merge_request_path}/notes`, note_parser);
for (const note of all_notes) {
if (!await is_relevant(note.author.username)) continue;
if (note.body.toLowerCase().includes("oki")) total += 1;
}
return total;
}