This repository was archived by the owner on Jul 28, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 9797)
9898
9999func (d * Daemon ) Start () {
100- err := d .do (true )
100+ err := d .do (false )
101101 if err != nil {
102102 d .logger .Println (err )
103103 }
@@ -106,7 +106,8 @@ func (d *Daemon) Start() {
106106 case <- d .doneChan :
107107 return
108108 case <- time .NewTicker (d .pollingInterval ).C :
109- err := d .do (false )
109+ isTimestampSet := d .lastTime != nil
110+ err := d .do (isTimestampSet )
110111
111112 if err != nil {
112113 d .logger .Println (err )
@@ -119,7 +120,7 @@ func (d *Daemon) Stop() {
119120 d .doneChan <- true
120121}
121122
122- func (d * Daemon ) do (isFirstTime bool ) error {
123+ func (d * Daemon ) do (isTimestampSet bool ) error {
123124 var (
124125 nextURL * string = nil
125126 resources []Resource
@@ -138,10 +139,9 @@ func (d *Daemon) do(isFirstTime bool) error {
138139
139140 params := url.Values {}
140141 params .Add ("q" , "type IN " + eventTypesFilter ())
141- if ! isFirstTime {
142+ if isTimestampSet {
142143 params .Add ("q" , "timestamp>" + d .lastTime .Format (ccTimeStampFormat ))
143144 }
144-
145145 err := fetch (params )
146146 if err != nil {
147147 return err
@@ -186,7 +186,7 @@ func (d *Daemon) do(isFirstTime bool) error {
186186 "version" : d .version ,
187187 }
188188
189- if ! isFirstTime {
189+ if isTimestampSet {
190190 err = d .analyticsClient .Enqueue (analytics.Track {
191191 UserId : d .UUID ,
192192 Event : eventType ,
@@ -199,10 +199,8 @@ func (d *Daemon) do(isFirstTime bool) error {
199199 return fmt .Errorf ("failed to send analytics: %v" , err )
200200 }
201201 }
202-
203202 return nil
204203}
205-
206204func (d * Daemon ) fetch (params url.Values , dest interface {}) error {
207205 req , err := http .NewRequest (http .MethodGet , d .ccHost + "/v2/events" , nil )
208206 if err != nil {
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=
4646github.com/golang/mock v1.1.1 /go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A =
4747github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM =
4848github.com/golang/protobuf v1.2.0 /go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U =
49+ github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 h1:WgfvpuKg42WVLkxNwzfFraXkTXPK36bMqXvMFN67clI =
4950github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 /go.mod h1:kj6hFWqfwSjFjLnYW5PK1DoxZ4O0uapwHRmd9jhln4E =
5051github.com/hooklift/iso9660 v1.0.0 h1:GYN0ejrqTl1qtB+g+ics7xxWHp7J2B1zmr25O9EyG3c =
5152github.com/hooklift/iso9660 v1.0.0 /go.mod h1:sOC47ru8lB0DlU0EZ7BJ0KCP5rDqOvx0c/5K5ADm8H0 =
You can’t perform that action at this time.
0 commit comments