BHTOM-Team / bhtom2

7 stars 2 forks source link

API for reading the target comments #197

Closed wyrzykow closed 1 week ago

wyrzykow commented 2 months ago

We need an API point for reading comments. All comments and comments per target. If possible, it would be great if API allowed for filtering also on some text contained in the comment(s). For example: request_body = { "target": "Gaia19dbf" } or request_body={ "targetid":"2986" }

should return JSON array of comments with fields: user=zsofianagy date=2024-03-12 text="Target created by Zsofia Nagy(zsofianagy) on 2024-03-12 21:00:36.414824+00:00" target="Gaia19dbf" targetid="2986"

Another example: request_body = { "user":"zsofianagy" } should return all comments added by this user, in the format as above.

Another example: request_body = { "text":"Chinese KATS" } should return an array of comments which contain this text, for example with target AT2024slv, targetid=3382. https://bh-tom2.astrolabs.pl/targets/3382/

Another request is for the date of the comment: request_body = { "date_before":2024-09-10T10:00:00 "date_after":2024-08-31T10:00:00 } should return all comments created between Aug. 31 and Sep. 10.

YuriiPurdenko commented 1 month ago

I'm not sure about this part: "If possible, it would be great if API allowed for filtering also on some text contained in the comment(s)."

@arturkrawczyk what do you think about this? Will it "kill" the database?

wyrzykow commented 1 month ago

Imagine a use case - I want to filter on all targets which contain in the comment phrase "spectrum". I could read all the targets and their comments, and then filter myself, but that's not the point.