You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
thumbsup/src/steps/summary.js

22 lines
550 B
JavaScript

exports.create = function (ctx) {
const stats = contextStats(ctx)
const messages = [
' Gallery generated successfully',
` ${stats.albums} albums, ${stats.photos} photos, ${stats.videos} videos`
]
return messages.join('\n')
}
function contextStats (ctx) {
return {
albums: countAlbums(0, ctx.album) - 1,
photos: ctx.files.filter(f => f.type === 'image').length,
videos: ctx.files.filter(f => f.type === 'video').length
}
}
function countAlbums (total, album) {
return 1 + album.albums.reduce(countAlbums, total)
}