summaryrefslogtreecommitdiff
path: root/backend-go/patch_all.py
blob: 7d541a10b28c4927a9334fdacc5243d6cbfcec20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import re

# 1. Update manager.go error handling and CreateRoute
manager_path = '/home/kboz/eve_haul/backend-go/internal/core/manager.go'
with open(manager_path, 'r') as f:
    text = f.read()

# Fix Wallet Error
text = text.replace(
    'm.Log = append([]string{"Wallet scope error: ensure token has wallet read permissions."}, m.Log...)',
    'm.Log = append([]string{fmt.Sprintf("Wallet Error: %v", err)}, m.Log...)'
)

# Fix ShortlistConfig creation (primary pass)
shortlist1 = '''shortlist := ShortlistConfig{
CandidateLimit:   PrimaryCandidateLimit,
TypeLimit:        PrimaryTypeLimit,
StationPairLimit: PrimaryStationPairLimit,
}'''
shortlist1_new = '''shortlist := ShortlistConfig{
CandidateLimit:   PrimaryCandidateLimit,
TypeLimit:        PrimaryTypeLimit,
StationPairLimit: PrimaryStationPairLimit,
RankMode:         "and",
}'''
text = text.replace(shortlist1, shortlist1_new)

# Fix ShortlistConfig creation (fallback pass)
shortlist2 = '''shortlist = ShortlistConfig{
CandidateLimit:   FallbackCandidateLimit,
TypeLimit:        FallbackTypeLimit,
StationPairLimit: FallbackStationPairLimit,
}'''
shortlist2_new = '''shortlist = ShortlistConfig{
CandidateLimit:   FallbackCandidateLimit,
TypeLimit:        FallbackTypeLimit,
StationPairLimit: FallbackStationPairLimit,
RankMode:         "and",
}'''
text = text.replace(shortlist2, shortlist2_new)

with open(manager_path, 'w') as f:
    f.write(text)


# 2. Update route.go Ship Struct with correct JSON tags
route_path = '/home/kboz/eve_haul/backend-go/internal/core/route.go'
with open(route_path, 'r') as f:
    r_text = f.read()

old_struct = '''type Ship struct {
TaxRate          float64
ProfitThreshold  float64
MaxCapital       float64
SnipeThreshold   float64
Location        int
Cargo           float64
MaxWarpSpeed     float64
MaxSubwarpSpeed  float64
GankersAreas     map[string]float64
PlayerCost       float64
RiskCost         float64
ShipCost         float64
}'''

new_struct = '''type Ship struct {
TaxRate          float64            `json:"tax_rate"`
ProfitThreshold  float64            `json:"profit_threshold"`
MaxCapital       float64            `json:"max_capital"`
SnipeThreshold   float64            `json:"snipe_profit_threshold"`
Location         int                `json:"location"`
Cargo            float64            `json:"cargo"`
MaxWarpSpeed     float64            `json:"max_warp_speed"`
MaxSubwarpSpeed  float64            `json:"max_subwarp_speed"`
GankersAreas     map[string]float64 `json:"gankers_areas"`
PlayerCost       float64            `json:"player_cost"`
RiskCost         float64            `json:"risk_cost"`
ShipCost         float64            `json:"ship_cost"`
}'''

r_text = r_text.replace(old_struct, new_struct)
with open(route_path, 'w') as f:
    f.write(r_text)

print("Patch completed!")