Add initial date based heuristics
[contractdashboard.git] / heuristics / historyHeuristics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?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*/
 
 $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);
}