Skip to content

Commit

Permalink
feat: maybe done with audible-as-active
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Feb 28, 2021
1 parent 13a927f commit f9fa6d2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@typescript-eslint/explicit-function-return-type": ["off"],
"@typescript-eslint/no-var-requires": ["off"],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-use-before-define": "warn",
"@typescript-eslint/no-use-before-define": ["error", {"functions": false, "classes": false}],
"@typescript-eslint/no-unused-vars": ["warn", {"argsIgnorePattern": "^_"}],
"@typescript-eslint/no-this-alias": [
"warn",
Expand Down
15 changes: 9 additions & 6 deletions src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ export function canonicalEvents(params: DesktopQueryParams | AndroidQueryParams)
: '',
// Fetch browser events
params.bid_browsers
? browserEvents(params) +
// Include focused and audible browser events as indications of not-afk
(params.include_audible
? `audible_events = filter_keyvals(browser_events, "audible", [true]);
? isDesktopParams(params) &&
browserEvents(params) +
// Include focused and audible browser events as indications of not-afk
(params.include_audible
? `audible_events = filter_keyvals(browser_events, "audible", [true]);
not_afk = period_union(not_afk, audible_events);`
: '')
: '')
: '',
// Filter out window events when the user was afk
isDesktopParams(params) && params.filter_afk
Expand Down Expand Up @@ -190,7 +191,8 @@ export function fullDesktopQuery(
afkbucket: string,
filterAFK = true,
classes,
filterCategories: string[][]
filterCategories: string[][],
include_audible: boolean
): string[] {
// Escape `"`
browserbuckets = _.map(browserbuckets, escape_doublequote);
Expand All @@ -205,6 +207,7 @@ export function fullDesktopQuery(
classes: classes,
filter_classes: filterCategories,
filter_afk: filterAFK,
include_audible,
};

return querystr_to_array(
Expand Down
6 changes: 4 additions & 2 deletions src/store/modules/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface QueryOptions {
date?: string;
timeperiod?: TimePeriod;
filterAFK?: boolean;
includeAudible?: boolean;
filterCategories?: string[][];
force?: boolean;
}
Expand Down Expand Up @@ -215,7 +216,7 @@ const actions = {

async query_desktop_full(
{ state, commit, rootState, rootGetters },
{ timeperiod, filterCategories, filterAFK }: QueryOptions
{ timeperiod, filterCategories, filterAFK, includeAudible }: QueryOptions
) {
const periods = [timeperiodToStr(timeperiod)];
const classes = loadClassesForQuery();
Expand All @@ -225,7 +226,8 @@ const actions = {
state.buckets.afk[0],
filterAFK,
classes,
filterCategories
filterCategories,
includeAudible
);
const data = await this._vm.$aw.query(periods, q);

Expand Down
13 changes: 12 additions & 1 deletion src/views/activity/Activity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ div
b-form-group(label="Show/filter category" label-cols="5" label-cols-lg="4")
b-form-select(v-model="filterCategory", :options="categories")

div.row
div.col-md-12
b-form-group(label="Filter AFK" label-cols="11")
b-form-checkbox(v-model="filterAFK")
div.col-md-12
b-form-group(label="Browser audible as active" label-cols="11")
b-form-checkbox(v-model="includeAudible")

aw-devonly
b-btn(id="load-demo", @click="load_demo")
| Load demo data
Expand Down Expand Up @@ -143,6 +151,8 @@ export default {
return {
today: get_today(),
filterCategory: null,
includeAudible: true,
filterAFK: true,
new_view: {},
};
},
Expand Down Expand Up @@ -262,7 +272,8 @@ export default {
timeperiod: this.timeperiod,
host: this.host,
force: force,
filterAFK: true,
filterAFK: this.filterAFK,
includeAudible: this.includeAudible,
filterCategories: this.filterCategories,
});
},
Expand Down

0 comments on commit f9fa6d2

Please sign in to comment.