-
Notifications
You must be signed in to change notification settings - Fork 1
/
updates.go
61 lines (51 loc) · 1.27 KB
/
updates.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
51
52
53
54
55
56
57
58
59
60
61
package vangogh_local_data
import (
"fmt"
)
var interestingNewProductTypes = map[ProductType]bool{
CatalogProducts: true,
AccountProducts: true,
UserWishlistProducts: true,
Details: true,
}
var interestingUpdatedProductTypes = map[ProductType]bool{
UserWishlistProducts: true,
Details: true,
SteamAppNews: true,
}
func Updates(since int64) (map[string]map[string]bool, error) {
updates := make(map[string]map[string]bool)
for _, pt := range LocalProducts() {
vr, err := NewProductReader(pt)
if err != nil {
return nil, err
}
if interestingNewProductTypes[pt] {
createdAfter, err := vr.CreatedAfter(since)
if err != nil {
return nil, err
}
categorize(createdAfter,
fmt.Sprintf("new in %s", pt.HumanReadableString()),
updates)
}
if interestingUpdatedProductTypes[pt] {
updatedAfter, err := vr.UpdatedAfter(since)
if err != nil {
return nil, err
}
categorize(updatedAfter,
fmt.Sprintf("updates in %s", pt.HumanReadableString()),
updates)
}
}
return updates, nil
}
func categorize(ids []string, cat string, updates map[string]map[string]bool) {
for _, id := range ids {
if updates[cat] == nil {
updates[cat] = make(map[string]bool, 0)
}
updates[cat][id] = true
}
}