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