Beginnings of Heuristics work
[contractdashboard.git] / heuristics / runHeuristics.php
blob:a/heuristics/runHeuristics.php -> blob:b/heuristics/runHeuristics.php
<? <?php
if agency if (php_sapi_name() != "cli") {
if supplier  
if CN include_once ("../lib/common.inc.php");
  auth();
  include_once("heuristics.inc.php");
   
  // agency table missing JOIN agency ON contractnotice."agencyName"
  $query = 'SELECT *, case when "supplierABN" != 0 then "supplierABN"::text else "supplierName" end as "supplierID"
  FROM contractnotice
  WHERE DATE("importDate") = (select * from (SELECT DATE("importDate")
  FROM contractnotice ORDER BY "importDate" DESC limit 1) alias) limit 100';
  $query = $conn->prepare($query);
  $query->execute();
  databaseError($conn->errorInfo());
  foreach ($query->fetchAll() as $cn) {
  //get each new CN from latest update
  foreach ($heuristics as $heuristic => $description) {
  // run all heuristics
  runHeuristic($heuristic, $cn);
  }
  flush();
  }
  /*foreach agency
   
  aggregate agency metrics
   
  foreach supplier
   
  aggreate supplier metrics
   
  foreach CN
   
  aggregate CN metrics */
  }
?> ?>