Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid reporting negative session active time #7926

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions backend/private-graph/graph/schema.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6239,12 +6239,12 @@ select coalesce(email.Value, nullif(IP, ''), device.Value, Identifier) as key,
count(distinct ID) as num_sessions,
count(distinct date_trunc('day', CreatedAt)) as num_days_visited,
count(distinct date_trunc('month', CreatedAt)) as num_months_visited,
avg(ActiveLength) / 1000 / 60 as avg_active_length_mins,
max(ActiveLength) / 1000 / 60 as max_active_length_mins,
sum(ActiveLength) / 1000 / 60 as total_active_length_mins,
avg(Length) / 1000 / 60 as avg_length_mins,
max(Length) / 1000 / 60 as max_length_mins,
sum(Length) / 1000 / 60 as total_length_mins,
avg(greatest(0, ActiveLength)) / 1000 / 60 as avg_active_length_mins,
max(greatest(0, ActiveLength)) / 1000 / 60 as max_active_length_mins,
sum(greatest(0, ActiveLength)) / 1000 / 60 as total_active_length_mins,
avg(greatest(0, Length)) / 1000 / 60 as avg_length_mins,
max(greatest(0, Length)) / 1000 / 60 as max_length_mins,
sum(greatest(0, Length)) / 1000 / 60 as total_length_mins,
max(City) as location
from sessions final
left join (select *
Expand Down
2 changes: 1 addition & 1 deletion backend/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ func processEventChunk(ctx context.Context, a EventProcessingAccumulator, events
var diff time.Duration
if !a.LastEventTimestamp.IsZero() {
diff = event.Timestamp.Sub(a.LastEventTimestamp)
if diff.Seconds() <= MIN_INACTIVE_DURATION {
if diff > 0 && diff.Seconds() <= MIN_INACTIVE_DURATION {
a.ActiveDuration += diff
}
}
Expand Down
Loading