Skip to content

Commit

Permalink
fix: fixed filter by category on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed May 4, 2020
1 parent 7a2693d commit 80479d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/queries.ts
Expand Up @@ -75,18 +75,27 @@ export function windowQuery(
return querystr_to_array(code);
}

export function appQuery(appbucket: string, classes, filterAFK): string[] {
export function appQuery(
appbucket: string,
classes,
filterAFK: boolean,
filterCategories: string[][]
): string[] {
appbucket = appbucket.replace('"', '\\"');
const params: AndroidQueryParams = {
bid_android: appbucket,
classes: classes,
filter_afk: filterAFK,
};
const code = `
const code =
`
events = query_bucket("${params.bid_android}");
events = merge_events_by_keys(events, ["app"]);
events = categorize(events, ${JSON.stringify(params.classes)});
events = categorize(events, ${JSON.stringify(params.classes)});` +
(filterCategories
? `events = filter_keyvals(events, "$category", ${JSON.stringify(filterCategories)});`
: '') +
`
title_events = sort_by_duration(merge_events_by_keys(events, ["app", "classname"]));
app_events = sort_by_duration(merge_events_by_keys(title_events, ["app"]));
cat_events = sort_by_duration(merge_events_by_keys(events, ["$category"]));
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/activity.ts
Expand Up @@ -193,7 +193,7 @@ const actions = {
async query_android({ state, commit }, { timeperiod, filterCategories }: QueryOptions) {
const periods = [timeperiodToStr(timeperiod)];
const classes = loadClassesForQuery();
const q = queries.appQuery(state.buckets.android[0], classes, filterCategories);
const q = queries.appQuery(state.buckets.android[0], classes, true, filterCategories);
const data = await this._vm.$aw.query(periods, q).catch(this.errorHandler);
commit('query_window_completed', data[0]);
},
Expand Down

0 comments on commit 80479d2

Please sign in to comment.