Monorepo for Tangled tangled.org

appview: profile: limit events to 30

anirudh.fi a70bcbc6 efb1ad66

verified
Changed files
+5
appview
+5
appview/db/profile.go
··· 15 16 func MakeProfileTimeline(e Execer, forDid string) ([]ProfileTimelineEvent, error) { 17 timeline := []ProfileTimelineEvent{} 18 19 pulls, err := GetPullsByOwnerDid(e, forDid) 20 if err != nil { ··· 70 sort.Slice(timeline, func(i, j int) bool { 71 return timeline[i].EventAt.After(timeline[j].EventAt) 72 }) 73 74 return timeline, nil 75 }
··· 15 16 func MakeProfileTimeline(e Execer, forDid string) ([]ProfileTimelineEvent, error) { 17 timeline := []ProfileTimelineEvent{} 18 + limit := 30 19 20 pulls, err := GetPullsByOwnerDid(e, forDid) 21 if err != nil { ··· 71 sort.Slice(timeline, func(i, j int) bool { 72 return timeline[i].EventAt.After(timeline[j].EventAt) 73 }) 74 + 75 + if len(timeline) > limit { 76 + timeline = timeline[:limit] 77 + } 78 79 return timeline, nil 80 }