TOMToolkit / tom_base

The base Django project for a Target and Observation Manager
https://tom-toolkit.readthedocs.io
GNU General Public License v3.0
26 stars 46 forks source link

Add Additional Tables to the Lasair query options #1084

Open jchate6 opened 2 weeks ago

jchate6 commented 2 weeks ago

The user should be able to include additional tables, especially in the SQL Query search.

This is spun off from a conversation attached to

jchate6 commented 2 weeks ago

From @ms1228:

I am working with SAGUARO group and trying to run Lasair query in the SAGUARO TOM. This part of the code should be in: https://github.com/TOMToolkit/tom_base/blob/dev/tom_alerts/brokers/lasair.py From what I have seen, it looks like the sql query in the TOM doesn't allow me to call things like Sherlock classification that is available in Lasair. Is there some way to add additional query information that is used in Lasair? Here is a sample query I am trying to run: objects.objectId=sherlock_classifications.objectId AND objects.objectId=watchlist_hits.objectId AND watchlist_hits.wl_id=1 AND watchlist_hits.name=crossmatch_tns.tns_name AND sherlock_classifications.classification not in ("VS", "BS", "CV", "AGN") AND objects.ncandgp > 1 AND objects.jdmin > JDNOW() - 45 AND objects.g_minus_r < 0.5 AND ((objects.dmdt_r < -0.25) OR (objects.dmdt_g < -0.25) OR (objects.dmdt_r > 0.25) OR (objects.dmdt_r > 0.25)) AND ((objects.dmdt_r_err < 0.1) OR (objects.dmdt_g_err < 0.1)) AND objects.objectId NOT LIKE "ZTF17%" AND objects.objectId NOT LIKE "ZTF18%" AND objects.objectId NOT LIKE "ZTF19%" AND objects.objectId NOT LIKE "ZTF20%" AND objects.objectId NOT LIKE "ZTF21%" AND objects.objectId NOT LIKE "ZTF22%"

Response from @jchate6:

Right now, the only table we search is the objects table. Your query includes references to both the sherlock_classifications and the crossmatch_tns tables. If you are up for it, and want to give us a hand, we would really appreciate it if you could help us add the functionality we're missing to lasair.py and make a Pull Request.

There is a description of how to use the query API and a full list of schema that can be used in the query.