Skip to content

Commit 0282eec

Browse files
committed
feat: added categoryQuery support on Android, fixing 'Timeline (barchart)' visualization
1 parent 51330e4 commit 0282eec

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/queries.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,9 @@ export function activityQueryAndroid(androidbucket: string): string[] {
441441

442442
// Returns a query that yields a dict with a key "cat_events" which is an
443443
// array of one event per category, with the duration of each event set to the sum of the category durations.
444-
export function categoryQuery(params: MultiQueryParams | DesktopQueryParams): string[] {
444+
export function categoryQuery(
445+
params: MultiQueryParams | DesktopQueryParams | AndroidQueryParams
446+
): string[] {
445447
const q = `
446448
${isMultiParams(params) ? canonicalMultideviceEvents(params) : canonicalEvents(params)}
447449
cat_events = sort_by_duration(merge_events_by_keys(events, ["$category"]));

src/stores/activity.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ export const useActivityStore = defineStore('activity', {
293293
await this.query_editor_completed();
294294
}
295295

296-
if (this.window.available) {
297-
// Perform this last, as it takes the longest
298-
await this.query_category_time_by_period({ ...query_options });
296+
// Perform this last, as it takes the longest
297+
if (this.window.available || this.android.available) {
298+
await this.query_category_time_by_period(query_options);
299299
}
300300
} else {
301301
console.warn(
@@ -502,22 +502,28 @@ export const useActivityStore = defineStore('activity', {
502502
}
503503
}
504504

505+
const isAndroid = this.buckets.android[0] !== undefined;
505506
const categories = useCategoryStore().classes_for_query;
506507
// TODO: Clean up call, pass QueryParams in fullDesktopQuery as well
507508
// TODO: Unify QueryOptions and QueryParams
508509
const query = queries.categoryQuery({
509-
bid_afk: this.buckets.afk[0],
510-
bid_window: this.buckets.window[0],
511510
bid_browsers: this.buckets.browser,
512511
bid_stopwatch:
513512
include_stopwatch && this.buckets.stopwatch.length > 0
514513
? this.buckets.stopwatch[0]
515514
: undefined,
516-
// bid_android: this.buckets.android,
517515
categories,
518516
filter_categories,
519517
filter_afk,
520518
always_active_pattern,
519+
...(isAndroid
520+
? {
521+
bid_android: this.buckets.android[0],
522+
}
523+
: {
524+
bid_afk: this.buckets.afk[0],
525+
bid_window: this.buckets.window[0],
526+
}),
521527
});
522528
const result = await getClient().query([period], query, {
523529
verbose: true,

0 commit comments

Comments
 (0)