--- a/heuristics/heuristics.inc.php
+++ b/heuristics/heuristics.inc.php
@@ -1,43 +1,47 @@
query($query);
- databaseError($conn->errorInfo());
+ // check if already ran
+ $query = "select count(*) from heuristic_results where heuristic_name = '$heuristicName' and \"CNID\" = '{$cn['CNID']}'";
+ $result = $conn->query($query);
+ databaseError($conn->errorInfo());
$r = $result->fetch(PDO::FETCH_BOTH);
- if ($r[0] == 0) {
- // if not, run now
- $hresults = call_user_func($heuristicName, $cn);
- if (!isset($hresults["heuristic_value"]) || !isset($hresults["raw_value"]) || !isset($hresults["mean"]) || !isset($hresults["stddev"])) {
- print_r($hresults);
- die("Missing field in heurtistic $heuristicName result");
- }
- $query = "insert into heuristic_results values('$heuristicName',
+ if ($r[0] == 0) {
+ // if not, run now
+ $hresults = call_user_func($heuristicName, $cn);
+ if (!isset($hresults["heuristic_value"]) || !isset($hresults["raw_value"]) || !isset($hresults["mean"]) || !isset($hresults["stddev"])) {
+ print_r($hresults);
+ die("Missing field in heurtistic $heuristicName result");
+ }
+ $query = "insert into heuristic_results values('$heuristicName',
'{$hresults["heuristic_value"]}',
'{$hresults["raw_value"]}',
'{$hresults["mean"]}',
'{$hresults["stddev"]}',
'{$cn["CNID"]}',
NOW(),
- '{$cn["publishDate"]}',
- '{$cn["agencyABN"]}',
- '{$cn["supplierID"]}'
+ '{$cn["publishDate"]}',"
+ //."'{$cn["agencyABN"]}',
+ ."0,'{$cn["supplierID"]}'
)";
- // save value and cn data via sql
- $result = $conn->query($query);
- $errors = $conn->errorInfo();
- if ($errors[2] == "") echo "Saved $heuristicName for {$cn["CNID"]}
\n";
- elseif (strpos($errors[2] , "Duplicate entry") === false) echo $hresults . " failed insert.
" . print_r($errors,true) . "
$query
\n";
- }
+ // save value and cn data via sql
+ $result = $conn->query($query);
+ $errors = $conn->errorInfo();
+ if ($errors[2] == "")
+ echo "Saved $heuristicName for {$cn["CNID"]}
\n";
+ elseif (strpos($errors[2], "Duplicate entry") === false)
+ echo $hresults . " failed insert.
" . print_r($errors, true) . "
$query
\n";
+ }
}
+
?>