Add initial date based heuristics
[contractdashboard.git] / heuristics / historyHeuristics.php
blob:a/heuristics/historyHeuristics.php -> blob:b/heuristics/historyHeuristics.php
--- a/heuristics/historyHeuristics.php
+++ b/heuristics/historyHeuristics.php
@@ -1,6 +1,25 @@
-      - unusual for agency/supplier
-        - previous low number of transactions 
-          - zero ie. new agency/supplier is huge score
-    - unusual value for time of year
+<?php     
+    // "unusual for agency/supplier due to previous low number of transactions "
+$heuristics["HISTORY_LOW_TRANSACTIONS"] = Array(
+	"description" => "unusual for agency/supplier due to previous low number of transactions "
+);
+function HISTORY_LOW_TRANSACTIONS($cn)
+{
+    	$averageContractPeriod = getAverageContractPeriod();
+	$diff = strtotime($cn['contractStart']) - strtotime($cn['publishDate']);
+	$days = intval($diff / 24);
+	return ($days > 45 ? 1 : 0);
+}
+ /*   - unusual value for time of year
         - compare to all other records in last 2 weeks
-        - ie. many large contracts in june so takes more to standout
+        - ie. many large contracts in june so takes more to standout*/
+ 
+ $heuristics["HISTORY_HIGH_VALUE_FOR_MONTH"] = Array(
+	"description" => "unusual value for time of year");
+function HISTORY_HIGH_VALUE_FOR_MONTH($cn)
+{
+    	$averageContractPeriod = getAverageContractPeriod();
+	$diff = strtotime($cn['contractStart']) - strtotime($cn['publishDate']);
+	$days = intval($diff / 24);
+	return ($days > 45 ? 1 : 0);
+}