Skip to content

Commit

Permalink
Merge pull request #13 from hidetak/develop
Browse files Browse the repository at this point in the history
add 'Done' data
  • Loading branch information
hidetak authored Jun 28, 2020
2 parents d889fc1 + 516422b commit 534b189
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
4 changes: 3 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ const writeListGroup = (trelloCsv, list, groupby) => {
pointsByGroup,
resultTimeByGroup,
reviewTimeByGroup,
doneByGroup,
} = trelloCsv.makeStatisticsUseGroupBy(list, groupby)
let csv = trelloCsv.makeCsvUseGroupBy(
groupby,
totalByGroup,
pointsByGroup,
resultTimeByGroup,
reviewTimeByGroup
reviewTimeByGroup,
doneByGroup
)
console.log(csv)
console.log(`total: ${total} hrs`)
Expand Down
36 changes: 33 additions & 3 deletions lib/trello-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,28 @@ class TrelloCSV {
return csv
}

checkListNameByCardId(listName, cardId) {
// get list id
let listId = undefined
for (let boardId in this._lists) {
for (let listItem of this._lists[boardId]) {
if (listItem.name === listName) {
listId = listItem.id
}
}
}
if (!listId || !this._cards[listId]) {
return false
}
// check card
for (let c of this._cards[listId]) {
if (c.id === cardId) {
return true
}
}
return false
}

makeStatisticsUseGroupBy(list, groupby) {
let total = 0
let totalResultTime = 0
Expand All @@ -349,7 +371,13 @@ class TrelloCSV {
let relatedCardIds = {}
let pointsByGroup = {}
let cardPointMap = {}
let doneByGroup = {}
for (let d of list) {
doneByGroup[d[groupby]] =
doneByGroup[d[groupby]] === false ||
!this.checkListNameByCardId('Done', d.cardId)
? false
: true
total += d.resultTime + d.reviewTime
totalResultTime += d.resultTime
totalReviewTime += d.reviewTime
Expand Down Expand Up @@ -388,6 +416,7 @@ class TrelloCSV {
pointsByGroup,
resultTimeByGroup,
reviewTimeByGroup,
doneByGroup,
}
}

Expand All @@ -396,11 +425,12 @@ class TrelloCSV {
totalByGroup,
pointsByGroup,
resultTimeByGroup,
reviewTimeByGroup
reviewTimeByGroup,
doneByGroup
) {
let csv = `"${groupby}","totalPoint","totalTime","totalResult","totalReview"\n`
let csv = `"${groupby}","totalPoint","totalTime","totalResult","totalReview","done"\n`
for (let k in totalByGroup) {
csv += `"${k}","${pointsByGroup[k]}","${totalByGroup[k]}","${resultTimeByGroup[k]}","${reviewTimeByGroup[k]}"\n`
csv += `"${k}","${pointsByGroup[k]}","${totalByGroup[k]}","${resultTimeByGroup[k]}","${reviewTimeByGroup[k]}","${doneByGroup[k]}"\n`
}
return csv
}
Expand Down

0 comments on commit 534b189

Please sign in to comment.