From: Alex Sadleir Date: Fri, 28 Mar 2014 00:16:28 +0000 Subject: Merge branch 'master' of ssh://apples.lambdacomplex.org/git/disclosr X-Git-Url: http://maxious.lambdacomplex.org/git/?p=disclosr.git&a=commitdiff&h=5830658f50a861c05be0cfcf58bc5ef667a37734 --- Merge branch 'master' of ssh://apples.lambdacomplex.org/git/disclosr Conflicts: admin/logo.svg Former-commit-id: 850f69e8af3bbfb3467f5708676d7bf99fce2571 --- --- a/admin/importOAICFOIrequests.php +++ b/admin/importOAICFOIrequests.php @@ -17,13 +17,13 @@ if ($row >= 1) { // print_r($data); $name = trim($data[2]); - echo "$name
"; +// echo "$name
"; if ($data[0] != "TOTALS" && $data[0] != "") { if (isset($nametoid[$name])) { $id = $nametoid[$name]; $timePeriod = $data[0] . "-Q" . $data[1]; - echo "$timePeriod
"; +// echo "$timePeriod
"; unset($data[0]); unset($data[1]); unset($data[2]); @@ -38,10 +38,13 @@ $result = Array("source" => "http://data.gov.au/dataset/freedom-of-information-quarterly-request-and-review-statistical-data-2011-12/"); foreach ($data as $key => $datum) { if ($datum != 0) { +// tODO prefix header with "FOI" +if (isset($stats[$id][$timePeriod][$key])) $datum += $stats[$id][$timePeriod][$key]; $result[trim($headers[$key])] = $datum; } } $stats[$id][$timePeriod] = $result; +// TODO merge if already exists //print_r($stats); } else { echo "
ERROR NAME MISSING FROM ID LIST

$row" . PHP_EOL; @@ -57,21 +60,24 @@ } fclose($handle); } +echo "all stats loaded successfuly"; foreach ($stats as $id => $stat) { echo $id . "
" . PHP_EOL; - $doc = $db->get($id); + $doc = $db->get($id); echo $doc->name . "
" . PHP_EOL; - print_r($stat); - die(); +// print_r($stat); // print_r($doc); $changed = false; if (!isset($doc->statistics)) { $changed = true; $doc->statistics = Array(); + } else { + $doc->statistics = object_to_array($doc->statistics); } foreach ($stat as $timePeriod => $value) { - if (!isset($doc->statistics->foiRequests->$timePeriod) - || $doc->statistics->foiRequests->$timePeriod != $value) { + if (!isset($doc->statistics["foiRequests"][$timePeriod]) + || $doc->statistics["foiRequests"][$timePeriod] != $value + ) { $changed = true; $doc->statistics["foiRequests"][$timePeriod] = $value; } @@ -81,6 +87,7 @@ } else { echo "not changed" . "
" . PHP_EOL; } +//print_r($doc);die(); } ?> --- a/admin/logo.svg +++ /dev/null @@ -1,58 +1,1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --- /dev/null +++ b/admin/massdelete.sh @@ -1,1 +1,10 @@ +for line in `curl "http://localhost:5984/disclosr-foidocuments/_design/app/_view/byAgencyID?reduce=false&keys=%5B\"5716ce0aacfe98f7d638b7a66b7f1040\"%5D&limit=600" | xargs -L1`; do +# echo $line + id=`echo $line | grep -Po '_id:.*?[^\\\],' | perl -pe 's/_id://; s/^//; s/,$//'` + rev=`echo $line | grep -Po 'rev:.*?[^\\\],'| perl -pe 's/rev://; s/^//; s/,$//'` + if [ -n "$id" ]; then + echo "curl -X DELETE http://localhost:5984/disclosr-foidocuments/$id?rev=$rev" + curl -X DELETE http://localhost:5984/disclosr-foidocuments/$id?rev=$rev + fi +done; --- a/admin/neo4jimporter/pom.xml +++ b/admin/neo4jimporter/pom.xml @@ -52,7 +52,7 @@ - Importer + StAXSample --- a/admin/neo4jimporter/src/main/java/StAXSample.java +++ b/admin/neo4jimporter/src/main/java/StAXSample.java @@ -35,13 +35,14 @@ } public static void main(String[] args) { - if (args.length != 1) { + /*if (args.length != 1) { System.out.println("Usage: StAXSample file.xml"); System.exit(-1); - } + } */ StAXSample ss = new StAXSample(); - ss.setFilename(args[0]); + //ss.setFilename(args[0]); + ss.setFilename("agency-sample.xml"); ss.run(); } --- a/admin/refreshDesignDoc.php +++ b/admin/refreshDesignDoc.php @@ -8,21 +8,13 @@ $obj->_id = "_design/" . urlencode("app"); $obj->language = "javascript"; $obj->views->all->map = "function(doc) { emit(doc._id, doc); };"; -$obj->views->byDate->map = "function(doc) { emit(doc.date, doc); };"; +$obj->views->byDate->map = "function(doc) { if (doc.title != \"Disclosure Log Updated\") { emit(doc.date, doc); } };"; $obj->views->byDateMonthYear->map = "function(doc) { emit(doc.date, doc); };"; $obj->views->byDateMonthYear->reduce = "_count"; $obj->views->byAgencyID->map = "function(doc) { emit(doc.agencyID, doc); };"; $obj->views->byAgencyID->reduce = "_count"; -$obj->views->fieldNames->map = ' -function(doc) { -for(var propName in doc) { - emit(propName, doc._id); - } - -}'; -$obj->views->fieldNames->reduce = 'function (key, values, rereduce) { - return values.length; -}'; +$obj->views->fieldNames->map = 'function(doc) { for(var propName in doc) { emit(propName, doc._id); }}'; +$obj->views->fieldNames->reduce = 'function (key, values, rereduce) { return values.length; }'; // allow safe updates (even if slightly slower due to extra: rev-detection check). $foidb->save($obj, true); @@ -120,15 +112,25 @@ } }"; $obj->views->getStatistics->map = -"function(doc) { - if (doc.statistics) { - for (var statisticSet in doc.statistics) { -for (var statisticPeriod in doc.statistics[statisticSet]) { - emit([statisticSet,statisticPeriod], doc.statistics[statisticSet][statisticPeriod]['value']); +" +function (doc) { + if (doc.statistics) { + for (var statisticSet in doc.statistics) { + for (var statisticPeriod in doc.statistics[statisticSet]) { + if (doc.statistics[statisticSet][statisticPeriod]['value']) { + emit([statisticSet, statisticPeriod], doc.statistics[statisticSet][statisticPeriod]['value']); + } else { + for (var statisticSubSet in doc.statistics[statisticSet][statisticPeriod]) { + if (statisticSubSet != 'source' && statisticSubSet != 'value') { + emit([statisticSubSet, statisticPeriod], doc.statistics[statisticSet][statisticPeriod][statisticSubSet]); + } + } + } + } + } + } } -} - } -}"; +"; $obj->views->getStatistics->reduce = '_sum'; // http://stackoverflow.com/questions/646628/javascript-startswith $obj->views->score->map = 'if(!String.prototype.startsWith){ --- a/documents/about.php +++ b/documents/about.php @@ -5,6 +5,7 @@ include_once('../include/common.inc.php'); ?>

About

+Written and managed by Alex Sadleir (maxious [at] lambdacomplex.org) --- a/documents/agency.php +++ b/documents/agency.php @@ -19,7 +19,7 @@
get_view("app", "byAgencyID", $_REQUEST['id'], false, false, false)->rows; foreach ($rows as $row) { //print_r($rows); @@ -31,6 +31,12 @@ } else { $rows = $foidocsdb->get_view("app", "byAgencyID?group=true", null, false, false, true)->rows; if ($rows) { +function cmp($a, $b) +{ + global $idtoname; + return strcmp($idtoname[$a->key], $idtoname[$b->key]); +} +usort($rows, "cmp"); foreach ($rows as $row) { echo '' . $idtoname[$row->key] . " (" . $row->value . " records)
\n"; } @@ -42,3 +48,4 @@ echo "next page "; include_footer_documents(); ?> + --- a/documents/charts.php +++ b/documents/charts.php @@ -5,18 +5,27 @@ $agenciesdb = $server->get_db('disclosr-agencies'); $idtoname = Array(); +$idtofoirequestssuccessful = Array(); foreach ($agenciesdb->get_view("app", "byCanonicalName")->rows as $row) { $idtoname[$row->id] = trim($row->value->name); + $foirequestssuccessful = 0; +if(isset($row->value->statistics->foiRequests)) { + foreach ($row->value->statistics->foiRequests as $statperiod) { + $statperiod=object_to_array($statperiod); + if (isset($statperiod["Requests for other information granted in full"])) $foirequestssuccessful += $statperiod["Requests for other information granted in full"]; + if (isset($statperiod["Requests for other information granted in part"])) $foirequestssuccessful += $statperiod["Requests for other information granted in part"]; + } +} + $idtofoirequestssuccessful[$row->id] =$foirequestssuccessful; } $foidocsdb = $server->get_db('disclosr-foidocuments'); - ?>
-
+