Skip to content

Commit

Permalink
Update dependencies and add lint build step
Browse files Browse the repository at this point in the history
  • Loading branch information
blazer82 committed Jun 12, 2024
1 parent 3b8181b commit 9f5334f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ jobs:
context: .
load: true
tags: ${{ env.TEST_TAG }}
- name: Lint
run: npm run lint
- name: Test
run: docker run --rm -e NEWRELIC_LICENSE_KEY="${{ env.NEWRELIC_LICENSE_KEY }}" ${{ env.TEST_TAG }} /analytodon-cli/bin/run hello world
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
"axios": "^0.27.2",
"megalodon": "^4.1.3",
"mongodb": "^4.12.1",
"newrelic": "^10.6.2",
"pino": "^8.15.0",
"newrelic": "^11.19.0",
"pino": "^9.2.0",
"timezone-support": "^3.1.0"
},
"devDependencies": {
"@oclif/test": "^2.2.12",
"@types/chai": "^4",
"@types/mocha": "^9.0.0",
"@types/node": "^16.18.4",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"chai": "^4",
"eslint": "^7.32.0",
"eslint-config-oclif": "^4",
"eslint-config-oclif-typescript": "^1.0.3",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint": "^8.57.0",
"eslint-config-oclif": "^5.2.0",
"eslint-config-oclif-typescript": "^3.1.7",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"mocha": "^9",
"oclif": "^3",
"prettier": "^2.8.4",
"prettier": "^3.3.2",
"shx": "^0.3.3",
"ts-node": "^10.9.1",
"tslib": "^2.4.1",
Expand Down
27 changes: 15 additions & 12 deletions src/helpers/createInitialAccountStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,21 @@ export const createInitialAccountStats = async (db: Db, account: Document) => {
}
}

const calculatedStatsList = statsList.reduce((carry, stats, index) => {
if (!carry.length) {
return [{...stats}];
}
return [
...carry,
{
...stats,
followersCount: carry[index - 1].followersCount - stats.followersCount,
},
];
}, [] as typeof statsList);
const calculatedStatsList = statsList.reduce(
(carry, stats, index) => {
if (!carry.length) {
return [{...stats}];
}
return [
...carry,
{
...stats,
followersCount: carry[index - 1].followersCount - stats.followersCount,
},
];
},
[] as typeof statsList,
);

const croppedStatsList = calculatedStatsList.filter(
({day}) => day.getTime() >= actualStartDate.getTime() && day.getTime() <= actualEndDate.getTime(),
Expand Down
33 changes: 18 additions & 15 deletions src/helpers/createInitialTootStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,30 @@ export const createInitialTootStats = async (db: Db, account: Document) => {

const croppedStatsList = statsList.filter(({day}) => day.getTime() >= actualStartDate.getTime());

const calculatedStatsList = croppedStatsList.reduce((carry, stats, index) => {
if (!carry.length) {
return [{...stats}];
} else if (!stats.repliesCount && !stats.boostsCount && !stats.favouritesCount) {
const calculatedStatsList = croppedStatsList.reduce(
(carry, stats, index) => {
if (!carry.length) {
return [{...stats}];
} else if (!stats.repliesCount && !stats.boostsCount && !stats.favouritesCount) {
return [
...carry,
{
...stats,
repliesCount: carry[index - 1].repliesCount,
boostsCount: carry[index - 1].boostsCount,
favouritesCount: carry[index - 1].favouritesCount,
},
];
}
return [
...carry,
{
...stats,
repliesCount: carry[index - 1].repliesCount,
boostsCount: carry[index - 1].boostsCount,
favouritesCount: carry[index - 1].favouritesCount,
},
];
}
return [
...carry,
{
...stats,
},
];
}, [] as typeof statsList);
},
[] as typeof statsList,
);

await processInBatches(BATCH_SIZE, calculatedStatsList, (stats) =>
db.collection('dailytootstats').insertOne({
Expand Down

0 comments on commit 9f5334f

Please sign in to comment.