From: Richard W.M. Jones Date: Wed, 16 Nov 2016 15:48:05 +0000 (+0000) Subject: poll-bugzilla: Avoid adding new task to multiple tables. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=d17685b95a06a12bbdf3ce049049c7d667b384e3;p=todo.git poll-bugzilla: Avoid adding new task to multiple tables. Check the task is not present in any table before adding it to the 'todo' table. So if a task is retired then it doesn't get readded to 'todo' next time. --- diff --git a/poll_bugzilla.ml b/poll_bugzilla.ml index 5b51e1c..8704c8e 100644 --- a/poll_bugzilla.ml +++ b/poll_bugzilla.ml @@ -107,11 +107,19 @@ let () = values ($tagid, $taskid)"; (* Add the bug to the todo table with the appropriate - * deadline. + * deadline. But first check if it is present in any + * table. *) - let rows = + let r1 = + PGSQL(dbh) "select 1 from imminent where taskid = $taskid" in + let r2 = PGSQL(dbh) "select 1 from todo where taskid = $taskid" in - if rows <> [Some 1_l] then + let r3 = + PGSQL(dbh) "select 1 from ideas where taskid = $taskid" in + let r4 = + PGSQL(dbh) "select 1 from retired where taskid = $taskid" in + if r1 <> [Some 1_l] && r2 <> [Some 1_l] && + r3 <> [Some 1_l] && r4 <> [Some 1_l] then PGSQL(dbh) "insert into todo (taskid, deadline) values ($taskid, $my_deadline::date)";