poll-bugzilla: Avoid adding new task to multiple tables.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 16 Nov 2016 15:48:05 +0000 (15:48 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 16 Nov 2016 15:48:05 +0000 (15:48 +0000)
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.

poll_bugzilla.ml

index 5b51e1c..8704c8e 100644 (file)
@@ -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)";