diff --git a/.eslintrc b/.eslintrc index 003e714..34f463a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,6 +8,7 @@ "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], "ignorePatterns": ["**/*.js"], "rules": { + "no-prototype-builtins": "off", "prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], // Disallow arrow functions as expressions "func-style": ["warn", "declaration", { "allowArrowFunctions": false }], // Disallow the use of function expressions "@typescript-eslint/no-floating-promises": "error", diff --git a/output.csv b/output.csv deleted file mode 100644 index 469a6a6..0000000 --- a/output.csv +++ /dev/null @@ -1,3 +0,0 @@ -assignee,reward,https://pay.ubq.fi?claim=eyJwZXJtaXQiOnsicGVybWl0dGVkIjp7InRva2VuIjoiMHhlOTFEMTUzRTBiNDE1MThBMkNlOERkM0Q3OTQ0RmE4NjM0NjNhOTdkIiwiYW1vdW50IjoiMTUwMDAwMDAwMDAwMDAwMDAwMDAwIn0sIm5vbmNlIjoiNTk5NDM2NjEwMjQxMzM0NDI5MjYzNjE2ODYxMTA5MDc4NjEwNTk2MzQxOTQxMzYzMzQ0MzM0OTU0NTY1NjYxMjQwNjMwNTc4NDg1OTUiLCJkZWFkbGluZSI6IjExNTc5MjA4OTIzNzMxNjE5NTQyMzU3MDk4NTAwODY4NzkwNzg1MzI2OTk4NDY2NTY0MDU2NDAzOTQ1NzU4NDAwNzkxMzEyOTYzOTkzNSJ9LCJ0cmFuc2ZlckRldGFpbHMiOnsidG8iOiIweGY3NkYxQUNCNjYwMjBmODkzYzk1MzcxZjc0MDU0OUYzMTJERUEzZjEiLCJyZXF1ZXN0ZWRBbW91bnQiOiIxNTAwMDAwMDAwMDAwMDAwMDAwMDAifSwib3duZXIiOiIweGY4N2NhNDU4M0M3OTIyMTJlNTI3MjBkMTI3RTdFMEEzOEI4MThhRDEiLCJzaWduYXR1cmUiOiIweDBiMjQyNDg2N2FmOGU0YTM0NGExZjU4YWMwZTkxMjY3MDFhODliZjBmY2RiOTVlMTlmNz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4NjM0NjNhOTdkIiwiYW1vdW50IjoiMjczMDAwMDAwMDAwMDAwMDAwMDAifSwibm9uY2UiOiIyNjAwNzgzNzczNTE2ODg2MTUxMTA3ODM3MjA1OTcyNjc4OTEzODgxMDExMDM4ODc3NzU0NzAwOTUxMzYxMTkwNjg1ODIyODYwMDU1MiIsImRlYWRsaW5lIjoiMTE1NzkyMDg5MjM3MzE2MTk1NDIzNTcwOTg1MDA4Njg3OTA3ODUzMjY5OTg0NjY1NjQwNTY0MDM5NDU3NTg0MDA3OTEzMTI5NjM5OTM1In0sInRyYW5zZmVyRGV0YWlscyI6eyJ0byI6IjB4NDAwN0NFMjA4M2M3RjNFMTgwOTdhZUIzQTM5YmI4ZUMxNDlhMzQxZCIsInJlcXVlc3RlZEFtb3VudCI6IjI3MzAwMDAwMDAwMDAwMDAwMDAwIn0sIm93bmVyIjoiMHhmODdjYTQ1ODNDNzkyMjEyZTUyNzIwZDEyN0U3RTBBMzhCODE4YUQxIiwic2lnbmF0dXJlIjoiMHhjNmJmMGQyYmY1YjU1MTYwODFkYjE4NzgxNmFlODFiN2E3MjgzYmQ5YzdhMjhiNDZlZDUzNzQxN2FlMmUzMGEzMTUzODNhYWFmNTQ0NmZiODYxOGVlZjQxMmRhNGFmM2ViNDAyYzMwNTU1MGRhMTNlOGY4YmE5MGFkZjc0MTE1OTFjIn0=&network=100 -devpanther,159.15,1,1,0 -pavlovcik,27.3,0,0,1 \ No newline at end of file diff --git a/output/output.xlsx b/output/output.xlsx deleted file mode 100644 index 1c19f33..0000000 Binary files a/output/output.xlsx and /dev/null differ diff --git a/package-lock.json b/package-lock.json index a303ea9..d4bb978 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@octokit/types": "^12.4.0", "@sinclair/typebox": "^0.32.3", "dotenv": "^16.3.1", + "json": "^11.0.0", "json2csv": "^6.0.0-alpha.2", "octokit": "^3.1.2", "xlsx": "^0.18.5" @@ -4640,6 +4641,17 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/json": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/json/-/json-11.0.0.tgz", + "integrity": "sha512-N/ITv3Yw9Za8cGxuQqSqrq6RHnlaHWZkAFavcfpH/R52522c26EbihMxnY7A1chxfXJ4d+cEFIsyTgfi9GihrA==", + "bin": { + "json": "lib/json.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", diff --git a/package.json b/package.json index ff2b1bf..9fa9601 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@octokit/types": "^12.4.0", "@sinclair/typebox": "^0.32.3", "dotenv": "^16.3.1", + "json": "^11.0.0", "json2csv": "^6.0.0-alpha.2", "octokit": "^3.1.2", "xlsx": "^0.18.5" diff --git a/src/helpers/calculateReward.ts b/src/helpers/calculateReward.ts index a29a8ef..b099e27 100644 --- a/src/helpers/calculateReward.ts +++ b/src/helpers/calculateReward.ts @@ -1,6 +1,7 @@ import { UserType } from "../types/github"; import { getAllIssueComments, getCompletedIssues, getIssueAssignee, parsePermit } from "./issue"; import { AssigneeRewardMap } from "../types/miscellaneous"; +import { mergeRewards } from "./excel"; export async function parseRewards(owner: string, repo: string, issueNumber: number): Promise { const rewardMap: AssigneeRewardMap = {}; @@ -74,7 +75,7 @@ export async function calculateRepoReward(owner: string, repo: string) { for (let i = 0; i < issues.length; i++) { const issueNumber = issues[i].number; const reward = await parseRewards(owner, repo, issueNumber); - totalReward = { ...totalReward, ...reward }; + totalReward = mergeRewards(totalReward, reward); } return totalReward; } diff --git a/src/helpers/excel.ts b/src/helpers/excel.ts index adabc41..3577c83 100644 --- a/src/helpers/excel.ts +++ b/src/helpers/excel.ts @@ -1,4 +1,5 @@ import { createWriteStream } from "fs"; +import { AssigneeRewardMap } from "../types/miscellaneous"; function getMaxPermits(data: Record): number { let maxPermits = 0; @@ -38,3 +39,31 @@ export async function convertToCSV(data: Record