Browse Source

Limit the number of results

Thomas Jost 3 years ago
parent
commit
20801f30fe
Signed by: Thomas Jost <schnouki@schnouki.net> GPG Key ID: 3F3B990246141762
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      fav/ws.go

+ 5
- 0
fav/ws.go View File

@@ -14,6 +14,8 @@ import (
14 14
 const (
15 15
 	// HoursURL is the URL used to query a bus/tramway stop hours.
16 16
 	HoursURL = "http://www.reseau-stan.com/webservices/transinfoservice/api/timetables/v1/GetStopHours/json"
17
+	// MaxTimes is the maximum number of passing times for a single stop.
18
+	MaxTimes = 8
17 19
 )
18 20
 
19 21
 var (
@@ -143,6 +145,9 @@ func (fav *Favorite) getTimeTable(realtime bool) (*TimeTable, error) {
143 145
 			pt.Realtime = true
144 146
 		}
145 147
 		tt.PassingTimes = append(tt.PassingTimes, pt)
148
+		if len(tt.PassingTimes) >= MaxTimes {
149
+			break
150
+		}
146 151
 	}
147 152
 	return &tt, nil
148 153
 }

Loading…
Cancel
Save