Implemented import API endpoint#41
Conversation
|
Just wrote https://github.com/ErikBjare/smartertime2activitywatch that should convert a SmarterTime export into an importable ActivityWatch bucket. |
|
With the latest commit I was able to import a SmarterTime export through the API! |
|
This does not follow the format used in |
|
I fixed it locally and imported my current database on my desktop. For my export of 94mb it took 19minutes to import in aw-server with peewee. In aw-server-rust it took less than 2 minutes lol. |
|
As we have a export schema in aw-core I decided to break backwards compatibility and use that everywhere. |
|
I think I thought I fixed the export button? |
|
@ErikBjare Pretty much everything is inconsistent. Export button doesn't have metadata, we use different formats in /0/api/export and /0/api/import. I now try to use |
|
What is differing between the formats? Perhaps we should start versioning the exports? (using a version of 0 until stabilized) Perhaps the best is to have the export-all format be Also, apparently I had almost fixed the export button: https://github.com/ActivityWatch/aw-webui/blob/eb56c6194e65ce73ab29b868ea8121d936ba5144/src/views/Buckets.vue#L33 Anyway, the most urgent issue should be to implement the import view (both for imports and export of the whole-instance and specific buckets). |
The current format is {"buckets": [{bucket1}, {bucket2}]} The export format was
That's a comment, not a fix. IMO it doesn't make sense to even have a button for it if we know that we will change the format, just makes it confusing for the end-user since the exported data won't be able to be imported anyway.
Why do we need a view for this? What's wrong with just having a "Export all" and "Import bucket" buttons in the buckets view? IMO the most important thing is that the data is actually consistent, because otherwise everything else is simply unusable. |
Edit the schema, it's not like we use it for anything. The schema should be the specification (edit: On second thought, maybe not, it wasn't quite as expressive that I'd like it to be iirc).
We should settle on a format, and a button would help us validate through usage that they are working properly.
That'd be preferable, yes.
Even inconsistent exports have some value (for those seeking to use the data outside ActivityWatch, for example), but I get what you saying. We should finalize the export schema and test it asap, sorry that I did such a sloppy job last time. In addition, getting export/import to work on Android requires some extra work (both because of aw-server-rust, but also due to how the WebView needs special code to handle downloads/uploads) but once it works it would enable easily performed (but inconvenient) manual sync through the export/import cycle. This should help us prepare the web UI for cross-device functionality. |
|
Alright, when I get back home I'll revert it so it's back to the
Yes it has some some value, but I don't think it's worth the price of people later starting asking "why doesn't my buckets get imported?". If someone wants to export without the export button they could do that through the API and if they did it from the current web-ui button they'd have to know programming to parse the export anyway so at that point they'd probably either ask how to export or be able to find out how to do it themselves.
I'd assume that importing/exporting from files would be a rarely used feature on a smartphone, IMO we should prioritize getting sync working instead of spending time on this. |
|
I have now tested:
The format is now |
| buckets = data["buckets"] | ||
| return app.api.import_all(buckets), 200 | ||
| # If import comes from a form in th web-ui | ||
| if len(request.files) > 0: |
There was a problem hiding this comment.
Not really sure how I'm supposed to add support for this in aw-server-rust, I will have to investigate that.
|
Also, apparently I did fix the export button thing, but the fix is in this PR: https://github.com/ActivityWatch/aw-webui/pull/119/files#diff-32c6cbf8ae7a966f7e41ec78a6d775cbR16 |
|
@ErikBjare Looks identical to the code I wrote so I assume it has the same issue with browsers showing the preview of the JSON instead of prompting a file download? |
|
@ErikBjare Was able to fix the issue with it not being downloaded as a file by adding a header in this commit daa9e0b |
ErikBjare
left a comment
There was a problem hiding this comment.
LGTM! (Can't approve my own PR)
Stuff left to do:
Implement an import dialog in the web UI(not in this PR)Depends on ActivityWatch/aw-core#69