Skip to content
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

Get Events API null total #13

Open
esadek opened this issue Nov 2, 2024 · 5 comments
Open

Get Events API null total #13

esadek opened this issue Nov 2, 2024 · 5 comments

Comments

@esadek
Copy link
Contributor

esadek commented Nov 2, 2024

I am working through the quickstart and am getting total": null when using the Get Events API. The docs say "If null, the total is unknown" but I don't think this should be the case since ClickHouse contains only one event.

> curl -i -X GET \ 
   -H "Authorization: Bearer private-d613be4e-di03-4b02-9058-70aa4j04ff28" \
   'http://localhost:4000/events?event=ConnectedAccount'
   
HTTP/1.1 200 OK
access-control-allow-origin: *
access-control-allow-credentials: true
access-control-expose-headers: Authorization
content-type: application/json; charset=utf-8
content-length: 586
Date: Sat, 02 Nov 2024 00:48:52 GMT
Connection: keep-alive
Keep-Alive: timeout=72

{"results":[{"uuid":"094ea003-2e9c-41e2-9ad6-ed49bfa10d1a","type":"track","event":"ConnectedAccount","userId":"550e8400-e29b-41d4-a716-446655440000","properties":{"totalAccounts":4,"country":"Denmark"},"timestamp":"2024-11-02T00:15:25.000Z","parsedAt":"2024-11-02T00:15:31.211Z"},{"uuid":"d2c6194a-522b-48e6-b0b4-1aa8f652f253","type":"track","event":"ConnectedAccount","userId":"550e8400-e29b-41d4-a716-446655440000","properties":{"totalAccounts":2,"country":"Germany"},"timestamp":"2024-11-02T00:22:26.000Z","parsedAt":"2024-11-02T00:22:31.166Z"}],"limit":1000,"offset":0,"total":null}
@christianmat
Copy link
Contributor

This looks like a bug indeed. Feel free to open a PR. Given that it requires a secondary query to ClickHouse, we may want to have the total only be shown if it’s needed and add a flag / query param for it.

@esadek
Copy link
Contributor Author

esadek commented Nov 2, 2024

Can't null just be changed to results.length?

return {
results: results,
limit: maxRecords,
offset: offset ?? 0,
total: null,
}

@christianmat
Copy link
Contributor

The total is meant to reflect the total amount of results to be used with pagination (e.g. calculating total number of pages to show an end user).

@tuminzee
Copy link

@christianmat I would like to open a PR for this

@christianmat
Copy link
Contributor

@tuminzee go for it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants