Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/boost/rerun-chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func printContractChart(userID string, archive []*ei.LocalContract, percent int,
generousGift, _ = strconv.ParseBool(val)
}

processedIDs := make(map[string]bool)

for _, a := range archive {
contractID := a.GetContractIdentifier()
evaluation := a.GetEvaluation()
Expand All @@ -126,6 +128,8 @@ func printContractChart(userID string, archive []*ei.LocalContract, percent int,
}
}

processedIDs[contractID] = true

if c.ContractVersion == 2 {
maxCxp := c.CxpMax
if generousGift {
Expand Down Expand Up @@ -171,6 +175,57 @@ func printContractChart(userID string, archive []*ei.LocalContract, percent int,
}
}

if percent == -200 {
for _, contractID := range contractIDList {
if processedIDs[contractID] {
continue
}
c, ok := ei.GetEggIncContract(contractID)
if !ok {
continue
}
if c.ContractVersion == 2 {
evaluationCxp := 0.0
maxCxp := c.CxpMax
if generousGift {
maxCxp = c.CxpMaxGG
}
hasSiab := false
if generousGift {
if c.CxpMaxSiabGG > c.CxpMaxGG {
maxCxp = c.CxpMaxSiabGG
if c.CxpMaxSiabGG > evaluationCxp {
hasSiab = true
}
}
} else {
if c.CxpMaxSiab > c.CxpMax {
maxCxp = c.CxpMaxSiab
if c.CxpMaxSiab > evaluationCxp {
hasSiab = true
}
}
}

dayLabel := ""
if len(contractDayMap) > 0 {
dayLabel = contractDayMap[contractID]
}
rows = append(rows, chartRow{
contractID: contractID,
cxp: evaluationCxp,
maxCxp: maxCxp,
gap: maxCxp - evaluationCxp,
percent: 0.0,
validUntil: c.ValidUntil.Unix(),
dayLabel: dayLabel,
hasSiab: hasSiab,
maxCoopSize: c.MaxCoopSize,
})
}
}
}

session := &chartSession{
xid: xid.New().String(),
userID: userID,
Expand Down
Loading