-
Notifications
You must be signed in to change notification settings - Fork 2
/
feeds.go
50 lines (44 loc) · 1.18 KB
/
feeds.go
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
package mock
import (
"fmt"
"math/rand"
"time"
"github.com/acikkaynak/musahit-harita-backend/feeds"
"github.com/acikkaynak/musahit-harita-backend/repository"
)
func GetFeeds() (*feeds.Response, error) {
var response []feeds.Feed
for _, nh := range repository.NeighborhoodIdToMap {
response = append(response, feeds.Feed{
NeighborhoodId: nh.Id,
VolunteerData: rand.Intn(5) + 1,
})
}
return &feeds.Response{
Count: len(response),
Results: response,
}, nil
}
func GetFeedDetail(neighborhoodId int) (*feeds.FeedDetailResponse, error) {
var response feeds.FeedDetailResponse
for _, nh := range repository.NeighborhoodIdToMap {
if nh.Id == neighborhoodId {
response.NeighborhoodId = nh.Id
response.Intensity = rand.Intn(5) + 1
response.LastUpdateTime = time.Now().Add(-time.Minute * time.Duration(rand.Intn(60))).Format(time.RFC3339)
response.Details = make([]feeds.FeedDetail, 0)
for i := 0; i < rand.Intn(10)+1; i++ {
response.Details = append(response.Details, feeds.FeedDetail{
BuildingName: fmt.Sprintf("Building %d", i),
BallotBoxNos: []int{
i,
i + 1,
i + 2,
},
})
}
break
}
}
return &response, nil
}