server icon indicating copy to clipboard operation
server copied to clipboard

Export/Import TimeSpans as csv/json

Open jmattheis opened this issue 5 years ago • 12 comments

jmattheis avatar Nov 29 '19 08:11 jmattheis

Hi, is it implemented? I think yes, then where is documentation? Or I should use graphql? Thanks :))

Shahin-rmz avatar Jun 27 '22 14:06 Shahin-rmz

Not implemented, you've to use the graphql api.

jmattheis avatar Jun 27 '22 16:06 jmattheis

Would love to see this implemented some day. This is the main feature holding me back from making the plunge from Toggle.

brandon1024 avatar Jan 27 '24 19:01 brandon1024

Same ! Love Traggo but a time tracker where you can't export is useless. It basically means you put all the effort tracking your time but you can do nothing with all this data.

microSoftware avatar Apr 16 '24 21:04 microSoftware

The data is still yours, and you can export the data directly from the sqlite database with a query like this:

SELECT u.name,
       start_utc,
       end_utc,
       group_concat(key || ':' || string_value, ' ') AS tags
FROM time_spans ts
JOIN time_span_tags tst ON ts.id = tst.time_span_id
JOIN users u ON u.id = ts.user_id
GROUP BY time_span_id
$ sqlite3 data.db -header -csv "select u.name, start_utc, end_utc, group_concat(key || ':' || string_value, ' ') as tags from time_spans ts join time_span_tags tst on ts.id = tst.time_span_id join users u on u.id = ts.user_id group by time_span_id"
name,start_utc,end_utc,tags
admin,"2024-01-01 00:00:00+00:00","2024-01-01 00:09:00+00:00","proj:traggo type:review issue:747"
admin,"2024-01-01 00:13:00+00:00","2024-01-01 02:17:00+00:00","proj:gotify type:review issue:676"
admin,"2024-01-01 02:29:00+00:00","2024-01-01 04:07:00+00:00","proj:gotify type:review issue:676"
admin,"2024-01-01 04:18:00+00:00","2024-01-01 06:22:00+00:00","proj:gotify type:review issue:676"
admin,"2024-01-01 06:34:00+00:00","2024-01-01 08:58:00+00:00","proj:gotify type:review issue:676"
admin,"2024-01-01 09:09:00+00:00","2024-01-01 10:21:00+00:00","type:support with:nicories"
admin,"2024-01-01 10:27:00+00:00","2024-01-01 11:24:00+00:00","proj:traggo type:work issue:747"
admin,"2024-01-01 11:39:00+00:00","2024-01-01 12:09:00+00:00","proj:gotify type:work issue:676"
admin,"2024-01-01 12:21:00+00:00","2024-01-01 14:34:00+00:00","proj:traggo type:work issue:747"

jmattheis avatar Apr 17 '24 17:04 jmattheis

Forcing users to query the database manually to generate a CSV export is kinda brutal :laughing: Wouldn't it be pretty straightforward to wrap this in a simple API?

brandon1024 avatar Apr 17 '24 17:04 brandon1024

Yes, but it depends on what kind of customization the api should support. I could imagine that some users want the tag as separate columns and not as just text.

jmattheis avatar Apr 17 '24 18:04 jmattheis

I don't think we need anything fancy in the beginning. Even the simplest API (start/end date as query params) would suffice for now. Additional features can come after that :slightly_smiling_face:

brandon1024 avatar Apr 17 '24 18:04 brandon1024

The data is still yours, and you can export the data directly from the sqlite database with a query like this:

SELECT u.name,
       start_utc,
       end_utc,
       group_concat(key || ':' || string_value, ' ') AS tags
FROM time_spans ts
JOIN time_span_tags tst ON ts.id = tst.time_span_id
JOIN users u ON u.id = ts.user_id
GROUP BY time_span_id
$ sqlite3 data.db -header -csv "select u.name, start_utc, end_utc, group_concat(key || ':' || string_value, ' ') as tags from time_spans ts join time_span_tags tst on ts.id = tst.time_span_id join users u on u.id = ts.user_id group by time_span_id"
name,start_utc,end_utc,tags
admin,"2024-01-01 00:00:00+00:00","2024-01-01 00:09:00+00:00","proj:traggo type:review issue:747"
admin,"2024-01-01 00:13:00+00:00","2024-01-01 02:17:00+00:00","proj:gotify type:review issue:676"
admin,"2024-01-01 02:29:00+00:00","2024-01-01 04:07:00+00:00","proj:gotify type:review issue:676"
admin,"2024-01-01 04:18:00+00:00","2024-01-01 06:22:00+00:00","proj:gotify type:review issue:676"
admin,"2024-01-01 06:34:00+00:00","2024-01-01 08:58:00+00:00","proj:gotify type:review issue:676"
admin,"2024-01-01 09:09:00+00:00","2024-01-01 10:21:00+00:00","type:support with:nicories"
admin,"2024-01-01 10:27:00+00:00","2024-01-01 11:24:00+00:00","proj:traggo type:work issue:747"
admin,"2024-01-01 11:39:00+00:00","2024-01-01 12:09:00+00:00","proj:gotify type:work issue:676"
admin,"2024-01-01 12:21:00+00:00","2024-01-01 14:34:00+00:00","proj:traggo type:work issue:747"

thanks that'll do it for me. Else, i'm sure there is a library already out there to export data into csv from a sqlite database.

microSoftware avatar Apr 18 '24 23:04 microSoftware