Skip to content

Commit

Permalink
include year into stats, to avoid showing last year's videos as new
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduards Sizovs committed Dec 26, 2019
1 parent 8124d30 commit 256ffcc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions generateStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const dayjs = require('dayjs')
const GitFile = require('./classes/GitFile')

const commitMonth = rev => dayjs(rev.commit.date()).format('MMMM')
const commitYear = rev => dayjs(rev.commit.date()).format('YYYY')

module.exports = books =>
Promise
Expand All @@ -15,14 +16,14 @@ module.exports = books =>
console.warn('😵 Cannot get git history of ' + book.location)
return undefined
} else {
return { isbn: isbn.toString(), month: commitMonth(firstRev) }
return { isbn: isbn.toString(), month: commitMonth(firstRev), year: commitYear(firstRev) }
}
})
)
)
.then(stats => stats
.filter(stat => stat)
.reduce((acc, curr) =>
Object.assign(acc, {[curr.month]: [curr.isbn].concat(acc[curr.month] || [])}), {}
Object.assign(acc, {[curr.year + "/" + curr.month]: [curr.isbn].concat(acc[curr.year + "/" + curr.month] || [])}), {}
))
.then(JSON.stringify)

0 comments on commit 256ffcc

Please sign in to comment.