Skip to content

Commit 8ebcf34

Browse files
committed
Fix check if phone is offline
1 parent 1a21d4f commit 8ebcf34

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

api/cmd/experiments/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ func main() {
3434
logger := container.Logger()
3535

3636
logger.Info("Starting experiments")
37-
38-
sendSingle()
37+
deleteContacts(container)
3938
}
4039

4140
func chunkBy[T any](items []T, chunkSize int) (chunks [][]T) {
@@ -49,15 +48,17 @@ func deleteContacts(container *di.Container) {
4948
sendgrid := container.MarketingService()
5049
logger := container.Logger()
5150

52-
b, err := os.ReadFile("28462979_cf6f5478-3e15-4666-95d7-59149df6f0fd.csv") // just pass the file name
51+
b, err := os.ReadFile("28462979_873d41e1-cd34-4782-8992-0762ed247667.csv") // just pass the file name
5352
if err != nil {
5453
logger.Fatal(stacktrace.Propagate(err, "cannot read file"))
5554
}
5655

5756
lines := strings.Split(string(b), "\n")[1:]
5857
var contacts []string
5958
for _, line := range lines {
60-
contacts = append(contacts, strings.ReplaceAll(strings.Split(line, ",")[17], "\"", ""))
59+
if len(line) >= 17 {
60+
contacts = append(contacts, strings.ReplaceAll(strings.Split(line, ",")[17], "\"", ""))
61+
}
6162
}
6263

6364
chunks := chunkBy(contacts, 100)

api/pkg/services/heartbeat_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (service *HeartbeatService) Monitor(ctx context.Context, params *HeartbeatM
303303
}
304304

305305
if time.Now().UTC().Sub(heartbeat.Timestamp) > (heartbeatCheckInterval*4) &&
306-
time.Now().UTC().Sub(heartbeat.Timestamp) < (heartbeatCheckInterval*5) && !monitor.PhoneIsOffline() {
306+
time.Now().UTC().Sub(heartbeat.Timestamp) < (heartbeatCheckInterval*5) && monitor.PhoneOnline {
307307
return service.handleFailedMonitor(ctx, heartbeat.Timestamp, params)
308308
}
309309

0 commit comments

Comments
 (0)