From: Maxious Date: Sat, 22 Sep 2012 13:28:44 +0000 Subject: amon key X-Git-Url: http://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=f78eef75f421c62b15fb637b04f8706e46947d6f --- amon key --- --- 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/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/displaySupplier.php +++ b/displaySupplier.php @@ -26,7 +26,7 @@ FROM contractnotice WHERE ' . $supplierQ . ' ' . $standardQ . ' ORDER BY value DESC'; - echo $query; + $query = $conn->prepare($query); --- /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:2464', + 'protocol' => 'http', + 'secret_key' => "JBcSUdFOi5lK0vCjLjbHDpQamcBnRA4iV7QLaTADeDQ")); +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,9 +119,28 @@ function include_header($title) { global $start; ?> - - + + <?php echo $title; ?> - Contract Dashboard --- a/lib/graphs.inc.php +++ b/lib/graphs.inc.php @@ -220,7 +220,7 @@ global $conn; $agency = "AusAid"; $topX = 15; - $query = 'SELECT SUM(value) as val, "supplierName" FROM contractnotice WHERE (extract ("YEAR" from "contractStart") >= :startYear) AND "childCN" is null AND "agencyName" = :agency + $query = 'SELECT SUM(value) as val, "supplierName" FROM contractnotice WHERE extract ("YEAR" from "contractStart") >= :startYear AND "childCN" is null AND "agencyName" like :agency GROUP BY lower(supplierName) ORDER BY val DESC limit $topX'; $query = $conn->prepare($query); $query->bindParam(":startYear", $startYear); @@ -235,7 +235,7 @@ } - $query = 'SELECT sum(a.val) as value, count(1) as count from (SELECT SUM(value) as val, "supplierName" FROM contractnotice WHERE (extract ("YEAR" from "contractStart") >= :startYear) AND "childCN" is null and "agencyName" = :agency + $query = 'SELECT sum(a.val) as value, count(1) as count from (SELECT SUM(value) as val, "supplierName" FROM contractnotice WHERE (extract ("YEAR" from "contractStart") >= :startYear) AND "childCN" is null and "agencyName" like :agency GROUP BY lower("supplierName") ORDER BY val DESC LIMIT 18446744073709551610 OFFSET $topX) as a'; $query = $conn->prepare($query); $query->bindParam(":startYear", $startYear); --- a/search_autosuggest.php +++ b/search_autosuggest.php @@ -47,7 +47,7 @@ ); } $query = "SELECT \"CNID\", description, value FROM contractnotice -WHERE to_tsvector('english', description) @@ to_tsquery('english', :input)"; +WHERE to_tsvector('english', description) @@ plainto_tsquery('english', :input)"; $query = $conn->prepare($query); $agencyName = $input . '%'; $query->bindParam(":input", $input); @@ -84,3 +84,4 @@ echo ""; } ?> +