-
Notifications
You must be signed in to change notification settings - Fork 4
/
decl.go
72 lines (57 loc) · 1.98 KB
/
decl.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
62
63
64
65
66
67
68
69
70
71
72
// Package rts implements Real Time Statistics calculations module
package rts
import (
"github.com/ottemo/commerce/env"
)
import (
"sync"
"time"
)
// Package global constants
const (
ConstCollectionNameRTSSalesHistory = "rts_sales_history"
ConstCollectionNameRTSVisitors = "rts_visitors"
// ConstCollectionNameRTSReferrals = "rts_referrals"
ConstReferrerTypeDirect = 0
ConstReferrerTypeSite = 1
ConstReferrerTypeSearch = 2
ConstVisitorOnlineSeconds = 10
ConstTimeDay = time.Hour * 24
ConstErrorModule = "rts"
ConstErrorLevel = env.ConstErrorLevelActor
ConstConfigPathCheckoutPath = "general.app.checkout_path"
)
// Package global variables
var (
updateSync sync.RWMutex
// referrers = make(map[string]int) // collects and counts refers from external sites
statistic = make(map[int64]*ActionsMade) // information about per hour site activity
monthStatistic = new(ActionsMade) // information total month activity
lastUpdate = time.Now() // last update timer for day reset
// reflects session state:
// 1) not present - new visit,
// 2) false - addToCart not happened,
// 3) true - addToCart happened
visitState = make(map[string]bool)
)
// ActionsMade contains info of visits, cart create and sales made for a hour
type ActionsMade struct {
Visit int // count site visits
Cart int // count times products was added to cart
Sales int // count of orders visitors made
TotalVisits int // total visits count
SalesAmount float64 // count sales
VisitCheckout int // count visitors reached checkout
SetPayment int // count payment methods used
}
// SellerInfo represents particular product in TopSellers struct
type SellerInfo struct {
Name string // product name
Image string // product image
Count int // times bought
}
// OnlineReferrer holds information about visit referer type and visit time
// type OnlineReferrer struct {
// referrerType int
// time time.Time
// }