Skip to content

fix(query): expose pulsetime param in q2_flood - #142

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/flood-pulsetime-param
Jul 21, 2026
Merged

fix(query): expose pulsetime param in q2_flood#142
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/flood-pulsetime-param

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Problem

The Work Time Report in aw-webui generates queries like:

events_0 = flood(query_bucket("aw-watcher-window_Host"), 300);

where 300 is the user-configured break time in seconds. The query language wrapper q2_flood only accepted one argument, causing:

{"type": "QueryInterpreterException", "message": "Tried to call function flood with invalid amount of arguments"}

This breaks the Work Time Report completely (ActivityWatch/activitywatch#1361).

Fix

The underlying flood() transform in aw_transform/flood.py already accepts pulsetime: float = 5 as an optional parameter. This PR exposes it in the query language:

# Before
def q2_flood(events: list) -> List[Event]:
    return flood(events)

# After
def q2_flood(events: list, pulsetime: float = 5) -> List[Event]:
    return flood(events, pulsetime)

The default is unchanged (5 seconds), so all existing single-argument flood() calls are unaffected.

Test

Added test_query2_flood_with_pulsetime which verifies:

  • flood(events) with the default 5s pulsetime leaves a 60s gap unfilled (2 events remain)
  • flood(events, 300) with a 300s pulsetime fills the 60s gap (1 merged event)

Fixes ActivityWatch/activitywatch#1361

The Work Time Report generates flood(bucket, 300) where 300 is the
break time in seconds. The underlying flood() transform already accepts
pulsetime as an optional kwarg (default 5s), but q2_flood only accepted
one argument, causing a QueryInterpreterException on every Work Time
Report query.

Fixes ActivityWatch/activitywatch#1361
@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR exposes the flood pulse-time parameter in the query language. The main changes are:

  • Adds an optional pulsetime argument to q2_flood.
  • Forwards the argument to the existing flood transform.
  • Tests default and explicit pulse-time behavior across datastore implementations.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
aw_query/functions.py Exposes and forwards the optional flood pulse time while preserving the existing default.
tests/test_query2.py Adds integration coverage for default and explicit pulse-time query calls.

Reviews (1): Last reviewed commit: "fix(query): expose pulsetime param in q2..." | Re-trigger Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

@ErikBjare
ErikBjare merged commit c4d31b8 into ActivityWatch:master Jul 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Work Time Report: flood() called with invalid number of arguments (QueryInterpreterException)

2 participants