Skip to content

Commit c52c945

Browse files
committed
Merge branch 'devel'
2 parents 261ac39 + c93d308 commit c52c945

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
master-v6.2.4
1+
master-v6.2.5

photometry/taskmanager.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def build_constraints(priority=None, starid=None, sector=None, cadence=None,
4141
Returns:
4242
list: List of strings containing constraints for database. The constraints should be
4343
joined with "AND" to have the desired effect.
44+
45+
.. codeauthor:: Rasmus Handberg <[email protected]>
4446
"""
4547

4648
constraints = []
@@ -61,12 +63,13 @@ def build_constraints(priority=None, starid=None, sector=None, cadence=None,
6163
if cbv_area is not None:
6264
constraints.append('todolist.cbv_area IN (' + ','.join([str(int(c)) for c in atleast_1d(cbv_area)]) + ')')
6365

64-
if tmag_min is not None and tmag_max is not None:
65-
constraints.append(f"(todolist.tmag BETWEEN {tmag_min:f} AND {tmag_max:f} OR (todolist.datasource LIKE 'tpf:%' AND CAST(SUBSTR(todolist.datasource,5) AS INTEGER) IN (SELECT DISTINCT starid FROM todolist t2 WHERE t2.datasource='tpf' AND t2.tmag BETWEEN {tmag_min:f} AND {tmag_max:f})))")
66-
elif tmag_min is not None:
67-
constraints.append(f"(todolist.tmag >= {tmag_min:f} OR (todolist.datasource LIKE 'tpf:%' AND CAST(SUBSTR(todolist.datasource,5) AS INTEGER) IN (SELECT DISTINCT starid FROM todolist t2 WHERE t2.datasource='tpf' AND t2.tmag >= {tmag_min:f})))")
68-
elif tmag_max is not None:
69-
constraints.append(f"(todolist.tmag <= {tmag_max:f} OR (todolist.datasource LIKE 'tpf:%' AND CAST(SUBSTR(todolist.datasource,5) AS INTEGER) IN (SELECT DISTINCT starid FROM todolist t2 WHERE t2.datasource='tpf' AND t2.tmag <= {tmag_max:f})))")
66+
if tmag_min is not None or tmag_max is not None:
67+
# To avoid having three separate cases, we join all cases by
68+
# putting in dummy upper and lower bounds in case they are
69+
# not provided. The values should be outside the range on any normal stars:
70+
tmag_min = -99 if tmag_min is None else tmag_min
71+
tmag_max = 99 if tmag_max is None else tmag_max
72+
constraints.append(f"((todolist.datasource NOT LIKE 'tpf:%' AND todolist.tmag BETWEEN {tmag_min:f} AND {tmag_max:f}) OR (todolist.datasource LIKE 'tpf:%' AND CAST(SUBSTR(todolist.datasource,5) AS INTEGER) IN (SELECT DISTINCT starid FROM todolist t2 WHERE t2.datasource='tpf' AND t2.tmag BETWEEN {tmag_min:f} AND {tmag_max:f})))")
7073

7174
if datasource is not None:
7275
constraints.append("todolist.datasource='ffi'" if datasource == 'ffi' else "todolist.datasource!='ffi'")
@@ -100,6 +103,8 @@ def __init__(self, todo_file, cleanup=False, overwrite=False, cleanup_constraint
100103
101104
Raises:
102105
FileNotFoundError: If TODO-file could not be found.
106+
107+
.. codeauthor:: Rasmus Handberg <[email protected]>
103108
"""
104109

105110
self.overwrite = overwrite
@@ -170,6 +175,7 @@ def __init__(self, todo_file, cleanup=False, overwrite=False, cleanup_constraint
170175
FOREIGN KEY (skipped_by) REFERENCES todolist(priority) ON DELETE RESTRICT ON UPDATE CASCADE
171176
);""")
172177
self.cursor.execute("CREATE UNIQUE INDEX IF NOT EXISTS diagnostics_lightcurve_idx ON diagnostics (lightcurve);")
178+
self.cursor.execute("CREATE INDEX IF NOT EXISTS todolist_datasource_idx ON todolist (datasource);")
173179
self.conn.commit()
174180

175181
# This is only for backwards compatibility.

0 commit comments

Comments
 (0)