diff --git a/daily_timesheet.py b/daily_timesheet.py index ae970dd..91a393c 100755 --- a/daily_timesheet.py +++ b/daily_timesheet.py @@ -212,6 +212,9 @@ def get_commits_today(repo_path: str, author: str, today: str) -> list[dict]: parts = line.split("|", 2) if len(parts) == 3: dt = datetime.strptime(parts[1], "%Y-%m-%d %H:%M") + # Filter ketat: pastikan author date = today (bukan commit dari hari lain yg di-rebase) + if dt.strftime("%Y-%m-%d") != today: + continue commits.append({ "hash": parts[0], "date": dt.strftime("%Y-%m-%d"), @@ -246,12 +249,14 @@ def commit_spans(sorted_commits: list[dict]) -> list[int]: def distribute_hours(weights: list[int], total: float = 8.0) -> list[float]: - """Pro-rata berdasarkan bobot (menit span). Sum = total. Adjustment di entry terakhir.""" + """Pro-rata berdasarkan bobot (menit span). Sum = total. Adjustment di entry terbesar.""" total_weight = sum(weights) raw = [Decimal(str(total)) * Decimal(w) / Decimal(total_weight) for w in weights] rounded = [float(r.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)) for r in raw] diff = round(total - sum(rounded), 2) - rounded[-1] = round(rounded[-1] + diff, 2) + # Terapkan koreksi ke entry terbesar agar tidak bisa jadi 0 + largest_idx = rounded.index(max(rounded)) + rounded[largest_idx] = round(rounded[largest_idx] + diff, 2) return rounded