commit e8d56cfbc1decf0069c884a2535ed15ba59b19dd
parent 1a8980feddb0b569d0f1747c0a831efc00348ddb
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Tue, 19 Mar 2024 19:30:00 -0700
Allow exporting specific time periods
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/pages/export.c b/pages/export.c
@@ -31,6 +31,7 @@ pageexport(struct pagedata *pd)
int n;
char *tmp;
enum kcgi_err (*serialize)(struct pagedata *, time_t) = serialize_ustr;
+ unsigned int period;
if (!pd->user)
return errorpage(pd, KHTTP_401);
@@ -46,7 +47,8 @@ pageexport(struct pagedata *pd)
serialize = serialize_epoch;
}
- if (gettimes(pd, pd->user->hash, 0, ×))
+ period = pd->req.fieldmap[KeyPeriod] ? pd->req.fieldmap[KeyPeriod]->parsed.i : 0;
+ if (gettimes(pd, pd->user->hash, period, ×))
return errorpage(pd, KHTTP_500);
if ((status = khttp_head(&pd->req, kresps[KRESP_STATUS],
@@ -54,7 +56,7 @@ pageexport(struct pagedata *pd)
(status = khttp_head(&pd->req, kresps[KRESP_CONTENT_TYPE],
"text/tsv")) != KCGI_OK ||
(status = khttp_head(&pd->req, kresps[KRESP_CONTENT_DISPOSITION],
- "attachment; filename=\"timekeeper-times.tsv\"")) != KCGI_OK ||
+ "attachment; filename=\"timekeeper-period-%d.tsv\"", period)) != KCGI_OK ||
(status = khttp_body(&pd->req)) != KCGI_OK) {
free(times);
return status;