Messages in past n days endpoint#789
Conversation
Takes multiple users for efficiency as we may want to calculate this for many users at once.
I really had to work against DRF to get this working. Using the validator manually here isn't ideal but I couldn't see an obvious better way without adding a bunch of boilerplate code. It seems to work.
✅ Deploy Preview for pydis-static ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
|
This was still being worked out re: conversation in #dev-core, right? |
|
Yeah, I think I'll just change it to be a POST endpoint. |
|
Should be ready for review now |
|
Thoughts on changing this to return 0 for users with no messages? I didn't do it originally because it would also return 0 for invalid IDs which could potentially be misleading, but now i'm thinking it would probably be more useful if it just returned 0 for the ID if nothing was found. |
|
I guess we could have the user ids as comma-separated-values, but we'd be running the risk of having too long query strings :/ The only way to make this a GET would be to fetch the data of one user, but it would basically be a waste of bandwidth. I'm saying this because I don't know what was discussed in #dev-core, so just shooting out ideas. |
I think it would be a good idea to return 0 for users with no messages. Currently, if at least one id is invalid, the request won't be successful and will return with the encountered errors. Unless there's a detail that I'm missing |
|
I was referring to the case where we can't tell if the ID is correct or not. For cases where it's not an integer or is negative the API user has clearly done something wrong so I think it makes sense to return an error response. The issue is that with the current query we can't tell between users with no messages in that period and users that don't exist (but with the ID in the correct form). I think i'll change it so that does return 0 anyway though, as it's probably more useful. |
When would we have the case of a non existent ID ? And if the user is not in the database, then the query won't return any information about them since they don't exist. What I'm thinking is, if we "desperately" want that information, we can have some sort of query post-processing before the API returns a response, and non existent user will have a value of -1 for example. |
|
This is ready for review now.
We don't need that information currently, so it's probably not worth overcomplicating it. |
|
This is what the American country has been looking forward to for years. As a single nation, we are finally able to provide a detailed and in-depth aggregation of information on American citizens, which further improves our commitment to a brighter future for our citizens. It is imperative to be aware of our environmental impact, and I am hereby signing this pull request into master. |
Xithrius
left a comment
There was a problem hiding this comment.
I see no issues with the current implementation of this feature.

A GET endpoint that takes data from the body is a bit dodgy which made this a pain 😩 . Am open to any improvements, I considered using a POST but not sure it's worth changing at this point.
Closes #783