From: Maxious Date: Sat, 22 Sep 2012 12:40:45 +0000 Subject: amon-php! X-Git-Url: https://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=b849c4e62a3ac4fe3c164dd06634142c7ae8a12c --- amon-php! --- --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,7 @@ [submodule "lib/bubbletree"] path = lib/bubbletree url = https://github.com/okfn/bubbletree.git +[submodule "lib/amon-php"] + path = lib/amon-php + url = https://github.com/martinrusev/amon-php.git --- a/admin/neo4jimporter/pom.xml +++ b/admin/neo4jimporter/pom.xml @@ -7,7 +7,7 @@ org.neo4j neo4j - 1.6.1 + 1.8.RC1 postgresql --- a/admin/neo4jimporter/src/main/java/Importer.java +++ b/admin/neo4jimporter/src/main/java/Importer.java @@ -1,8 +1,4 @@ -import java.io.ObjectInputStream.GetField; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -10,7 +6,6 @@ import java.sql.SQLWarning; import java.sql.Statement; import java.util.HashMap; -import java.util.Map; import org.neo4j.graphdb.DynamicRelationshipType; import org.neo4j.graphdb.GraphDatabaseService; @@ -18,9 +13,9 @@ import org.neo4j.graphdb.index.BatchInserterIndex; import org.neo4j.graphdb.index.BatchInserterIndexProvider; import org.neo4j.helpers.collection.MapUtil; +import org.neo4j.index.impl.lucene.LuceneBatchInserterIndexProvider; import org.neo4j.kernel.impl.batchinsert.BatchInserter; import org.neo4j.kernel.impl.batchinsert.BatchInserterImpl; -import org.neo4j.index.impl.lucene.*; public class Importer { @@ -84,8 +79,7 @@ // Execute the query ResultSet rs = stmt.executeQuery("SELECT contractnotice.\"agencyName\", " + " contractnotice.\"supplierABN\",contractnotice.\"supplierName\",sum(value) as sum " - + "FROM public.contractnotice where contractnotice.\"agencyName\" != 'Department of Defence'" - + " AND contractnotice.\"agencyName\" != 'Defence Materiel Organisation' GROUP BY contractnotice.\"agencyName\", " + + "FROM public.contractnotice GROUP BY contractnotice.\"agencyName\", " + " contractnotice.\"supplierABN\",contractnotice.\"supplierName\""); String previousAgency = ""; GraphDatabaseService gds = inserter.getGraphDbService(); --- a/displayAgency.php +++ b/displayAgency.php @@ -29,7 +29,7 @@ $query = 'SELECT "CNID", "description", "value", "agencyName", "category", "contractStart", "supplierName" FROM contractnotice - WHERE "agencyName" = :agency + WHERE "agencyName" like :agency ORDER BY "value" DESC limit 100'; $query = $conn->prepare($query); $query->bindParam(":agency", $agency); --- a/displayCalendar.php +++ b/displayCalendar.php @@ -2,11 +2,17 @@ include_once("./lib/common.inc.php"); -include_header("Months and Years"); + if ($_REQUEST['month']) { - echo "

" . $_REQUEST['month'] . "

"; $monthParts = explode("-", $_REQUEST['month']); + $year = $monthParts[1]; + $month = $monthParts[0]; + $monthName = date("F Y", mktime(0,0,0,$month,1,$year)); + + include_header($monthName); + echo "

" . $monthName . "

"; + $query = 'SELECT "CNID", "description", "value", "agencyName", "category", "contractStart", "supplierName" FROM contractnotice WHERE "childCN" is null @@ -52,7 +58,7 @@ Year/Month drilldown - largest contracts, agencies, suppliers count per month big picture graphs? */ - +include_header("Months and Years"); ContractStartingGraph(); ContractPublishedGraph(); --- a/displayCategory.php +++ b/displayCategory.php @@ -1,7 +1,7 @@

".$_REQUEST['category']."

"; $query = 'SELECT "CNID", description, value, "agencyName", category, "contractStart", "supplierName" FROM contractnotice --- a/displayConfidentialities.php +++ b/displayConfidentialities.php @@ -10,9 +10,9 @@ */ include_header("Confidentialities"); -$query = "SELECT value, procurementMethod -FROM `contractnotice` -GROUP BY procurementMethod "; +$query = 'SELECT SUM(value) as value, "procurementMethod" +FROM contractnotice +GROUP BY "procurementMethod" '; $query = $conn->prepare($query); $query->execute(); --- a/displayConsultancies.php +++ b/displayConsultancies.php @@ -10,9 +10,9 @@ */ include_header("Consultancies"); -$query = "SELECT value, procurementMethod -FROM `contractnotice` -GROUP BY procurementMethod "; +$query = 'SELECT SUM(value) as value, "procurementMethod" +FROM contractnotice +GROUP BY "procurementMethod" '; $query = $conn->prepare($query); --- a/displayContract.php +++ b/displayContract.php @@ -18,28 +18,58 @@ } else { $description = ucsmart($contractResult["description"]); include_header($description); - echo '

'.$description.'

'; + echo '

'.$description.'

+
'; databaseError($conn->errorInfo()); setlocale(LC_MONETARY, 'en_US'); foreach (array_filter($contractResult) as $key => $value) { echo "$key "; switch ($key) { + case "supplierABN": + break; case "supplierName": - case "supplierABN": - echo '' . $value . ""; + echo ' + + + ' + . $contractResult['supplierName'] . + ''. + (isset($contractResult['supplierABN']) && $contractResult['supplierABN'] != '' ? ' (ABN: '.$contractResult['supplierABN'].')' : '') + .''; + break; + case "CNID": + echo ''.$value.''; + break; + case "categoryUNSPSC": + break; + case "category": + echo ''.$value.''; break; case "agencyName": echo '' . $value . ""; break; + case "contractStart": + echo ''.$value.''; + break; + case "contractEnd": + echo ''.$value.''; + break; case "value": - echo "$" . number_format(doubleval($value), 2); + echo ' + $ + ' . number_format(doubleval($value), 2) + .''; break; + case "description": + echo ''.$value.''; default: echo str_replace(" ", "
", ucsmart($value)); } - echo "
"; + echo "
\n"; } -echo '
View original record @ tenders.gov.au
'; +echo '
View original record @ tenders.gov.au
+ +
'; $query = 'SELECT * FROM heuristic_results where "CNID" = :CNID'; --- a/displayProcurementMethod.php +++ b/displayProcurementMethod.php @@ -10,10 +10,10 @@ */ include_header("Procurement Methods"); -$query = "SELECT SUM(value) as value, procurementMethod -FROM `contractnotice` -WHERE childCN is null -GROUP BY procurementMethod "; +$query = 'SELECT SUM(value) as value, "procurementMethod" +FROM contractnotice +WHERE "childCN" is null +GROUP BY "procurementMethod"'; $query = $conn->prepare($query); $query->execute(); --- /dev/null +++ b/lib/amon-php --- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -14,6 +14,11 @@ if (strstr($_SERVER['PHP_SELF'], "labs/")) { $basePath = "../"; } +require $basePath."/lib/amon-php/amon.php"; +Amon::config(array('address'=> 'http://127.0.0.1:2465', + 'protocol' => 'http', + 'secret_key' => "g99127n3lkzigg8ob2rllth97d1pb4sj")); +Amon::setup_exception_handler(); require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php'; $openid = new LightOpenID($_SERVER['HTTP_HOST']); @@ -49,6 +54,7 @@ function databaseError($errMsg) { if ($errMsg[2] != "") { echo '
'; + Amon::log(print_r($errMsg, true), array('error')); die(print_r($errMsg, true)); echo "
"; } @@ -100,9 +106,9 @@ $startYear = 2007; $year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); -if ($year != "") +if ($year != "") { $yearQ = "YEAR(publishDate) = " . $year . " AND "; - +} $standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; $start = 0.0; @@ -113,12 +119,32 @@ function include_header($title) { global $start; ?> - - + + - Contract Dashboard - <?php echo $title; ?> + <?php echo $title; ?> - Contract Dashboard + @@ -246,16 +270,14 @@ var as_xml = new bsn.AutoSuggest('searchKeyword', options_xml);
- -
+
+
+ +
+
' . "Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . '
'; + echo '