From 1a411570a5afbd9abf961e5454d79de2baf6d134 Mon Sep 17 00:00:00 2001 From: tycrek Date: Sat, 31 Jul 2021 09:25:45 -0600 Subject: [PATCH 1/5] Fixed metrics script --- metrics.js | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/metrics.js b/metrics.js index c0c0067..5adcf6d 100644 --- a/metrics.js +++ b/metrics.js @@ -8,33 +8,40 @@ const TLog = require('@tycrek/log'); const log = new TLog({ level: 'debug', timestamp: { enabled: false } }); module.exports = () => { - const data = fs.readJsonSync(path.join(__dirname, 'data.json')); + const data = require('./data'); const { users } = fs.readJsonSync(path.join(__dirname, 'auth.json')); Object.keys(users).forEach((token) => users[token].count = 0); let totalSize = 0; let oldSize = 0; - Object.values(data).forEach(({ token, size }) => { - try { - totalSize += size; - if (token === undefined) oldSize += size; // skipcq: JS-0127 - else { - if (!users[token].size) users[token].size = 0; - users[token].size += size; - users[token].count++; - } - } catch (ex) { - // Silently handle missing tokens from dev environment -tycrek - } - }); + let d; - // Get AWS size - bucketSize() + data.get() + .then((D) => d = D.map(([, resource]) => resource)) + .then(() => { + console.log(d); + d.forEach(({ token, size }) => { + try { + totalSize += size; + if (token === undefined) oldSize += size; // skipcq: JS-0127 + else { + if (!users[token].size) users[token].size = 0; + users[token].size += size; + users[token].count++; + } + } catch (ex) { + // Silently handle missing tokens from dev environment -tycrek + } + }); + + // Get AWS size + return bucketSize(); + }) .then((s3size) => { log.info('---- Usage metrics ----') .blank() .info('Users', Object.keys(users).length) - .info('Files', Object.keys(data).length) + .info('Files', Object.keys(d).length) .info('S3 size', s3enabled ? s3size : '--') .blank() .info('Total size', formatBytes(totalSize)) From 2554f9b0f8037e1d27bfcd792d67eabe25e0cd2c Mon Sep 17 00:00:00 2001 From: tycrek Date: Sat, 31 Jul 2021 10:21:40 -0600 Subject: [PATCH 2/5] added config.yml --- .github/ISSUE_TEMPLATE/config.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..2d14c28 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Official Support Discord + url: https://discord.gg/wGZYt5fasY + about: Join the Discord for faster help & to chat with other users From 4ce2e4d7315a0f7c749c47ebeefe39358d9b4ae5 Mon Sep 17 00:00:00 2001 From: tycrek Date: Sat, 31 Jul 2021 10:22:03 -0600 Subject: [PATCH 3/5] PR template is now markdown since I didn't read the docs fully --- .github/PULL_REQUEST_TEMPLATE/feature.md | 27 +++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE/feature.yml | 32 ----------------------- 2 files changed, 27 insertions(+), 32 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE/feature.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE/feature.yml diff --git a/.github/PULL_REQUEST_TEMPLATE/feature.md b/.github/PULL_REQUEST_TEMPLATE/feature.md new file mode 100644 index 0000000..35b20ba --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/feature.md @@ -0,0 +1,27 @@ +--- +name: feature +about: Add new features or functionality +title: "[FEATURE] Title" +labels: enhancement +assignees: '' +projects: 1 + +--- + +## Checklist + + +- [x] I have read the Contributing Guidelines (coming soon) +- [ ] I acknowledge that any submitted code will be licensed under the [ISC License](https://github.com/tycrek/ass/blob/master/LICENSE) +- [ ] I confirm that submitted code is my own work +- [ ] I have tested the code, and confirm that it works + +## Enviroment + + +- Operating System: +- Node version: +- NPM version: + +## Description + diff --git a/.github/PULL_REQUEST_TEMPLATE/feature.yml b/.github/PULL_REQUEST_TEMPLATE/feature.yml deleted file mode 100644 index 9f1c5bf..0000000 --- a/.github/PULL_REQUEST_TEMPLATE/feature.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: feature -description: "For PR's that add new features or functionality" -title: "[FEATURE] Title" -labels: enhancement -assignees: - - tycrek -projects: 1 -body: - - type: markdown - value: "## Thank you for contributing to ass!" - - type: markdown - value: "Please fill out this form to the best of your ability" - - type: checkboxes - attributes: - label: Checklist - id: checklist - options: - - label: "I have read the Contributing Guidelines (coming soon)" - - label: "I acknowledge that any submitted code will be licensed under the [ISC License](https://github.com/tycrek/ass/blob/master/LICENSE)" - required: true - - type: input - label: Relevant Issue - id: issue - description: "Issue this PR resolves, if applicable" - placeholder: "#123" - - type: textarea - label: Description - description: "Describe your PR in detail" - id: description - validations: - required: true - From 9d61bdaec0a0fe98cda78d420cdd06edeb3d7d85 Mon Sep 17 00:00:00 2001 From: tycrek Date: Sat, 31 Jul 2021 10:26:02 -0600 Subject: [PATCH 4/5] Fixed assignment operators should not be used in return statements --- metrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics.js b/metrics.js index 5adcf6d..9287689 100644 --- a/metrics.js +++ b/metrics.js @@ -17,7 +17,7 @@ module.exports = () => { let d; data.get() - .then((D) => d = D.map(([, resource]) => resource)) + .then((D) => (d = D.map(([, resource]) => resource))) .then(() => { console.log(d); d.forEach(({ token, size }) => { From 8af3ed72ab86ff3b021d790730a93a4be5537ae0 Mon Sep 17 00:00:00 2001 From: tycrek Date: Sat, 31 Jul 2021 10:26:18 -0600 Subject: [PATCH 5/5] Fixed initialization in variable declarations against recommended approach --- metrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics.js b/metrics.js index 9287689..e10d14e 100644 --- a/metrics.js +++ b/metrics.js @@ -14,7 +14,7 @@ module.exports = () => { let totalSize = 0; let oldSize = 0; - let d; + let d = []; data.get() .then((D) => (d = D.map(([, resource]) => resource)))