Deploy to K8s / deploy (push) Successful in 20s
Go (go/) becomes the primary implementation. The original Python version moves to legacy/ and is kept runnable; new features are still built in both (see the Dual implementation rule in CLAUDE.md). - git mv app.py, scripts/, templates/, tests/, pyproject.toml, uv.lock and build/ into legacy/ - Makefile: Python targets point at legacy/, venv in legacy/.venv, CREDENTIALS_PATH exported for the root .secret/ file - CI and make image build the Python image with legacy/ as context; the Makefile is no longer copied into the image - legacy/.dockerignore moved to the context root so it takes effect - CLAUDE.md, docs/README.md, Go comments, fixture README, capture script and VS Code launch config updated to the new layout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"fuj-management/go/internal/config"
|
|
"sort"
|
|
"strings"
|
|
|
|
domreconcile "fuj-management/go/internal/domain/reconcile"
|
|
)
|
|
|
|
// buildPaymentsResponse constructs the PaymentsResponse wire type.
|
|
// Mirrors legacy/scripts/views.py:build_payments_view_model.
|
|
func buildPaymentsResponse(
|
|
txns []domreconcile.Transaction,
|
|
memberNames []string,
|
|
) PaymentsResponse {
|
|
grouped := groupRawPaymentsByPerson(txns, memberNames)
|
|
|
|
// Add unmatched/unknown bucket for transactions with no person set.
|
|
const unknownKey = "Unmatched / Unknown"
|
|
for _, tx := range txns {
|
|
if strings.TrimSpace(tx.Person) == "" {
|
|
grouped[unknownKey] = append(grouped[unknownKey], rawTxFromDomain(tx))
|
|
}
|
|
}
|
|
// Sort the unknown bucket newest-first (others are sorted in groupRawPaymentsByPerson).
|
|
if rows, ok := grouped[unknownKey]; ok {
|
|
sort.Slice(rows, func(i, j int) bool { return rows[i].Date > rows[j].Date })
|
|
grouped[unknownKey] = rows
|
|
}
|
|
|
|
sortedPeople := make([]string, 0, len(grouped))
|
|
for p := range grouped {
|
|
sortedPeople = append(sortedPeople, p)
|
|
}
|
|
sort.Strings(sortedPeople)
|
|
|
|
return PaymentsResponse{
|
|
GroupedPayments: grouped,
|
|
SortedPeople: sortedPeople,
|
|
AttendanceURL: "https://docs.google.com/spreadsheets/d/" + config.AttendanceSheetID + "/edit",
|
|
PaymentsURL: "https://docs.google.com/spreadsheets/d/" + config.PaymentsSheetID + "/edit",
|
|
}
|
|
}
|