Skip to content

Commit

Permalink
ラベル名一覧が一定の順番になるよう変更
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukuboshi committed Mar 28, 2024
1 parent f713ec0 commit 2084634
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/example-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,22 +306,30 @@ function writeSummaryToSheet(
// ヘッダー行を考慮して2行目から開始
let row = 2;

// 色番号ごとの工数をソートされたエントリを基にシートに書き込む
workHoursMap.forEach((hours, color) => {
// イベントの色番号を色名に変換
const colorName = colorMap[color];

// イベントの色名をラベル名に変換
// LabelMapを使用してラベル名一覧を順番にシートに書き込む
Object.keys(LabelMap).forEach(colorName => {
// カラー名に対応するラベル名を取得
const labelName = LabelMap[colorName];

// イベントの工数の割合を計算
const workPercentage = ((hours / totalWorkHours) * 100).toFixed(1);

// イベントの情報をシートに書き込む
sheet.getRange('I' + row).setValue(labelName);
sheet.getRange('J' + row).setValue(hours);
sheet.getRange('K' + row).setValue(workPercentage);
row++;
// ラベル名が空文字でない場合のみ処理を行う
if (labelName) {
// 色名に対応する色番号を取得
const color = Object.keys(colorMap).find(
key => colorMap[key] === colorName
);
// 色番号に対応する工数を取得(存在しない場合は0)
const hours = color ? workHoursMap.get(color) : 0;
// イベントの工数の割合を計算(存在しない場合は0)
const workPercentage = hours
? ((hours / totalWorkHours) * 100).toFixed(1)
: 0;

// イベントの情報をシートに書き込む
sheet.getRange('I' + row).setValue(labelName);
sheet.getRange('J' + row).setValue(hours);
sheet.getRange('K' + row).setValue(workPercentage);
row++;
}
});

// ラベル名一覧と工数合計が記載されている範囲を指定
Expand Down

0 comments on commit 2084634

Please sign in to comment.