0bcb96c442
web/handlers/reach.go: GET /reach (list), GET /reach/new (form),
GET /reach/{id} (detail), POST /reach (atomic Reach+Stash create
per D-071, redirect 302). Labels "Create a Reach" (not the banned
legacy word). G-027 validation (non-empty, <=128, no path separators,
no template syntax). 3 Reach templates extend base.html.
reach_test.go: httptest for all 4 routes + atomic create + 400/409
error paths + rendered-HTML lexicon check on BOTH 200 and error bodies
(G-026). handlers/server.go: clone-per-page template pattern (avoids
content-block collision across pages). Coverage 81.2% on web/handlers.
---ci---
project: oy
phase: 1
milestone: v0.6
status: execute
---/ci---
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package store
|
|
|
|
import (
|
|
"time"
|
|
|
|
identitytypes "github.com/oy/openyield/x/identity/types"
|
|
stashtypes "github.com/oy/openyield/x/stash/types"
|
|
)
|
|
|
|
// seed populates the store with a few pre-existing Reach/Stash pairs for the
|
|
// list view. All strings lexicon-clean ("Holder"/"Reach"/"Stash"; NOT the
|
|
// banned financial terms). Two fixtures: one mature (90+ active days),
|
|
// one immature (45 active days) so the Stash dashboard (P2) can show both
|
|
// states.
|
|
func (s *Store) seed() {
|
|
now := time.Now().Unix()
|
|
// Fixture 1: a mature Nomad (ActiveDays=92, MaxGapDays=10 -> IsMature()).
|
|
seedOne(s, "holder-alia", "pk-alia-001", now, 920000, 92, 10)
|
|
// Fixture 2: an immature Nomad (ActiveDays=45, MaxGapDays=5 -> not mature).
|
|
seedOne(s, "holder-bryn", "pk-bryn-002", now, 410000, 45, 5)
|
|
}
|
|
|
|
func seedOne(s *Store, holderID, pubKey string, now int64, balanceGrain int64, activeDays, maxGap uint32) {
|
|
reachID := "reach-" + holderID
|
|
stashID := "stash-" + holderID
|
|
s.reaches[holderID] = identitytypes.Reach{
|
|
ReachID: reachID,
|
|
HolderID: holderID,
|
|
CreatedAt: now - int64(activeDays)*86400,
|
|
PublicKey: pubKey,
|
|
IsNomad: true,
|
|
}
|
|
s.stashes[holderID] = stashtypes.Stash{
|
|
HolderID: holderID,
|
|
StashID: stashID,
|
|
CreatedAt: now - int64(activeDays)*86400,
|
|
LastActive: now,
|
|
BalanceGrain: balanceGrain,
|
|
}
|
|
s.stashActivities[stashID] = stashtypes.StashActivity{
|
|
StashID: stashID,
|
|
ActiveDays: activeDays,
|
|
MaxGapDays: maxGap,
|
|
LastActivityDay: now,
|
|
}
|
|
}
|