-
-
Notifications
You must be signed in to change notification settings - Fork 147
Compatibility patch for aw-import-screentime #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -317,6 +317,39 @@ export const useActivityStore = defineStore('activity', { | |||||
| filter_categories | ||||||
| ); | ||||||
| const data = await getClient().query(periods, q).catch(this.errorHandler); | ||||||
|
|
||||||
| // Post-process for iOS compatibility (swap app <-> title) | ||||||
| const androidBucket = this.buckets.android[0]; | ||||||
| const isIos = androidBucket && androidBucket.startsWith('aw-import-screentime'); | ||||||
|
|
||||||
| if (isIos && data && data[0] && data[0].title_events) { | ||||||
| data[0].title_events.forEach((e: IEvent) => { | ||||||
| // iOS events have 'app' (bundleID) and 'title'. We swap them. | ||||||
| // Check if title exists to avoid overwriting with undefined | ||||||
| if (e.data.title) { | ||||||
| const originalApp = e.data.app; | ||||||
| e.data.classname = originalApp; // Bundle ID (e.g. com.google.ios.youtube) | ||||||
| e.data.app = e.data.title; // Human Name (e.g. YouTube) | ||||||
| } | ||||||
| }); | ||||||
|
|
||||||
| // Re-aggregate app_events from the modified title_events | ||||||
| const new_app_events_map: Record<string, IEvent> = {}; | ||||||
| data[0].title_events.forEach((e: IEvent) => { | ||||||
| const app = e.data.app; | ||||||
| if (!new_app_events_map[app]) { | ||||||
| // Clone event to avoid reference issues | ||||||
| new_app_events_map[app] = { ...e, duration: 0, data: { ...e.data } }; | ||||||
| // Ensure we only keep the 'app' key for app_events to match standard structure | ||||||
| new_app_events_map[app].data = { app: app, $category: e.data.$category }; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Only preserving
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/stores/activity.ts
Line: 344:344
Comment:
**logic:** Only preserving `app` and `$category` in re-aggregated events discards `classname` and `title` which may be needed elsewhere
```suggestion
new_app_events_map[app].data = { app: app, classname: e.data.classname, $category: e.data.$category };
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||
| } | ||||||
| new_app_events_map[app].duration += e.duration; | ||||||
| }); | ||||||
|
|
||||||
| // Sort by duration desc | ||||||
| data[0].app_events = _.orderBy(_.values(new_app_events_map), ['duration'], ['desc']); | ||||||
| } | ||||||
|
|
||||||
| this.query_window_completed(data[0]); | ||||||
| }, | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,10 +98,15 @@ export const useBucketsStore = defineStore('buckets', { | |
| ); | ||
| }, | ||
| bucketsAndroid(): (host: string) => string[] { | ||
| return host => | ||
| this.bucketsByType(host, 'currentwindow').filter((id: string) => | ||
| return host => { | ||
| const android = this.bucketsByType(host, 'currentwindow').filter((id: string) => | ||
| id.startsWith('aw-watcher-android') | ||
| ); | ||
| const ios = this.bucketsByType(host, 'app').filter((id: string) => | ||
| id.startsWith('aw-import-screentime') | ||
| ); | ||
|
Comment on lines
+105
to
+107
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Filtering by generic type The PR description mentions these are from Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: src/stores/buckets.ts
Line: 105:107
Comment:
**logic:** Filtering by generic type `'app'` could match unintended buckets. Consider using a more specific filter or adding additional validation.
The PR description mentions these are from `aw-import-screentime` which should have a specific bucket type. Check actual bucket type from iOS imports to ensure correct filtering. What is the actual bucket type created by aw-import-screentime - is it truly just 'app' or something more specific?
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
||
| return [...android, ...ios]; | ||
| }; | ||
| }, | ||
| bucketsEditor(): (host: string) => string[] { | ||
| // fallback to a bucket with 'unknown' host, if one exists. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Events without
titleare skipped but still contribute to aggregated durations from server-side query. This creates mismatch betweentitle_eventsandapp_eventsreturned from query vs post-processed versions. Are there iOS events that legitimately don't have a title field, and if so should they be handled differently?Prompt To Fix With AI