Skip to content

Commit

Permalink
feat: added categoryQuery support on Android, fixing 'Timeline (barch…
Browse files Browse the repository at this point in the history
…art)' visualization
  • Loading branch information
ErikBjare committed Nov 22, 2023
1 parent 51330e4 commit 0282eec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ export function activityQueryAndroid(androidbucket: string): string[] {

// Returns a query that yields a dict with a key "cat_events" which is an
// array of one event per category, with the duration of each event set to the sum of the category durations.
export function categoryQuery(params: MultiQueryParams | DesktopQueryParams): string[] {
export function categoryQuery(
params: MultiQueryParams | DesktopQueryParams | AndroidQueryParams
): string[] {
const q = `
${isMultiParams(params) ? canonicalMultideviceEvents(params) : canonicalEvents(params)}
cat_events = sort_by_duration(merge_events_by_keys(events, ["$category"]));
Expand Down
18 changes: 12 additions & 6 deletions src/stores/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ export const useActivityStore = defineStore('activity', {
await this.query_editor_completed();
}

if (this.window.available) {
// Perform this last, as it takes the longest
await this.query_category_time_by_period({ ...query_options });
// Perform this last, as it takes the longest
if (this.window.available || this.android.available) {
await this.query_category_time_by_period(query_options);
}
} else {
console.warn(
Expand Down Expand Up @@ -502,22 +502,28 @@ export const useActivityStore = defineStore('activity', {
}
}

const isAndroid = this.buckets.android[0] !== undefined;
const categories = useCategoryStore().classes_for_query;
// TODO: Clean up call, pass QueryParams in fullDesktopQuery as well
// TODO: Unify QueryOptions and QueryParams
const query = queries.categoryQuery({
bid_afk: this.buckets.afk[0],
bid_window: this.buckets.window[0],
bid_browsers: this.buckets.browser,
bid_stopwatch:
include_stopwatch && this.buckets.stopwatch.length > 0
? this.buckets.stopwatch[0]
: undefined,
// bid_android: this.buckets.android,
categories,
filter_categories,
filter_afk,
always_active_pattern,
...(isAndroid
? {
bid_android: this.buckets.android[0],
}
: {
bid_afk: this.buckets.afk[0],
bid_window: this.buckets.window[0],
}),
});
const result = await getClient().query([period], query, {
verbose: true,
Expand Down

1 comment on commit 0282eec

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are screenshots of this commit:

Screenshots using aw-server v0.12.3b11 (click to expand)

Screenshots using aw-server-rust master (click to expand)

Screenshots using aw-server-rust v0.12.3b11 (click to expand)

Please sign in to comment.