Skip to content

Commit 34b8c93

Browse files
Jing-yilinclaude
andcommitted
fix(#29): resolve duplicate function and API mismatch from merge
Critical fixes discovered by Codex review: 1. [P0] Remove duplicate GetCampaignHistory function (lines 177-193) - Merge left two function definitions (178 and 217) - Kept the correct version with days parameter support 2. [P0] Remove sparkline from CampaignRowView - Line 18 called SparklineView(pid:) which no longer exists - Investor-friendly UI (develop) already has sparkline in CampaignDetailView - Loading history for every row would cause N+1 query performance issues Refs: backend/internal/handler/campaigns.go:178, ios/KickWatch/Sources/Views/CampaignRowView.swift:18 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 722a8fc commit 34b8c93

2 files changed

Lines changed: 7 additions & 28 deletions

File tree

backend/internal/handler/campaigns.go

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func ListCampaigns(client *service.KickstarterScrapingService) gin.HandlerFunc {
6262
// Cron only upserts campaigns from discover pages (which only show live ones),
6363
// but never marks rows as ended when they disappear/expire.
6464
q := db.DB.Where("state = 'live' AND deadline >= ?", time.Now()).Offset(offset).Limit(limit + 1)
65-
65+
6666
// Map sort to DB columns
6767
switch sort {
6868
case "trending", "hot":
@@ -74,11 +74,11 @@ func ListCampaigns(client *service.KickstarterScrapingService) gin.HandlerFunc {
7474
default:
7575
q = q.Order("velocity_24h DESC, percent_funded DESC")
7676
}
77-
77+
7878
if categoryID != "" {
7979
q = q.Where("category_id = ?", categoryID)
8080
}
81-
81+
8282
// Return DB results if we have data
8383
// Note: Once using DB cursors, always use DB to maintain cursor format consistency
8484
if err := q.Find(&campaigns).Error; err == nil {
@@ -89,13 +89,13 @@ func ListCampaigns(client *service.KickstarterScrapingService) gin.HandlerFunc {
8989
if hasMore {
9090
campaigns = campaigns[:limit]
9191
}
92-
92+
9393
var nextCursor interface{}
9494
if hasMore {
9595
nextOffset := offset + limit
9696
nextCursor = base64.StdEncoding.EncodeToString([]byte(strconv.Itoa(nextOffset)))
9797
}
98-
98+
9999
// Don't include total for DB queries (we don't track global count)
100100
c.JSON(http.StatusOK, gin.H{"campaigns": campaigns, "next_cursor": nextCursor})
101101
return
@@ -174,24 +174,6 @@ func GetCampaign(c *gin.Context) {
174174
c.JSON(http.StatusOK, campaign)
175175
}
176176

177-
// GetCampaignHistory returns daily pledge snapshots for a campaign, oldest first.
178-
func GetCampaignHistory(c *gin.Context) {
179-
pid := c.Param("pid")
180-
if !db.IsEnabled() {
181-
c.JSON(http.StatusServiceUnavailable, gin.H{"error": "database not available"})
182-
return
183-
}
184-
var snapshots []model.CampaignSnapshot
185-
if err := db.DB.
186-
Where("campaign_pid = ?", pid).
187-
Order("snapshot_date ASC").
188-
Find(&snapshots).Error; err != nil {
189-
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
190-
return
191-
}
192-
c.JSON(http.StatusOK, snapshots)
193-
}
194-
195177
func ListCategories(client *service.KickstarterScrapingService) gin.HandlerFunc {
196178
return func(c *gin.Context) {
197179
if db.IsEnabled() {

ios/KickWatch/Sources/Views/CampaignRowView.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ struct CampaignRowView: View {
1414
thumbnail
1515
info
1616
Spacer(minLength: 4)
17-
VStack(spacing: 6) {
18-
SparklineView(pid: campaign.pid)
19-
watchButton
20-
}
21-
.padding(.trailing, 16)
17+
watchButton
18+
.padding(.trailing, 16)
2219
}
2320
.padding(.vertical, 10)
2421
.padding(.leading, 16)

0 commit comments

Comments
 (0)