Beginings of scoring
Beginings of scoring


Former-commit-id: 25071f148abb2abe0e2436ec3b83a60f7394b665

file:a/about.php -> file:b/about.php
--- a/about.php
+++ b/about.php
@@ -6,6 +6,12 @@
     <h1><a href="about.php">About/FAQ</a></h1>
     <h4 class="subheader">Lorem ipsum.</h4>
 </div>
+<h2> What is this? </h2>
+Disclosr is a project to monitor Australian Federal Government agencies 
+compliance with their <a href="http://www.oaic.gov.au/publications/other_operational/foi_policy_frequently_asked_questions.html#_Toc291837571">"proactive disclosure requirements"</a>.
+OGRE (Open Government Realization Evaluation) is a ranking of compliance with these requirements.
+Prometheus is the agent which polls agency websites to assess compliance.
+
 <h2> Open everything </h2>
 all documents released CC-BY 3 AU
 Open source git @
@@ -15,7 +21,7 @@
 http://www.comlaw.gov.au/Browse/Results/ByTitle/AdministrativeArrangementsOrders/Current/Ad/0 defines departments
 Agencies can be found in the Schedule to an Appropriation Bill (budget), Schedule to FMA Regulations and/or Public Service Act.
 
-http://www.finance.gov.au/publications/flipchart/docs/FMACACFlipchart.pdf summarises these
+http://www.finance.gov.au/publications/flipchart/docs/FMACACFlipchart.pdf summarises these. view-source:https://www.tenders.gov.au/?event=public.advancedsearch.home is great for the suspended/active status
 
 When defining the hierachy, this system is designed towards monitoring accountablity. Thus large agencies that have registered their own ABN 
 and have their own accountablity mechanisms/website recieve a seperate record as a child of their department.
@@ -24,6 +30,11 @@
 This flows through to organisation name and other/past names. A department that accounts for an agency will list that agency as an other child name.
 As agencies themselves shift between departments, there may be scope for providing time ranges but typically the newest hierarchy will be the one recorded.
 A department/agency name will be the newest active name assigned to that ABN.
+
+ABN information is derived from the ABR. This is the definitive umpire about which former name should be linked to which current name. 
+For example "Department of Transport and Regional Services" became "Department of Infrastructure, Transport, Regional Development and Local Government" (same ABN)
+however it later split into "Department of Infrastructure and Transport" (same ABN) 
+and "Department of Regional Australia, Regional Development and Local Government" (new ABN).
 
 Statistical information from http://www.apsc.gov.au/stateoftheservice/1011/statsbulletin/section1.html#t2total https://www.apsedii.gov.au/apsedii/CustomQueryx33.shtml
 and individual annual reports.

--- a/include/couchdb.inc.php
+++ b/include/couchdb.inc.php
@@ -8,12 +8,34 @@
     $obj->_id = "_design/" . urlencode("app");
     $obj->language = "javascript";
     $obj->views->byABN->map = "function(doc) {   emit(doc.abn, doc); };";
-    $obj->views->byName->map = "function(doc) {   emit(doc.name, doc); };";
+    $obj->views->byName->map = "function(doc) {   emit(doc.name, doc);
+ for (name in doc.otherNames) {
+if (doc.otherNames[name] != '' && doc.otherNames[name] != doc.name) {
+       	 emit(doc.otherNames[name], doc); 
+}
+        }
+};";
     $obj->views->byLastModified->map = "function(doc) {   emit(doc.metadata.lastModified, doc); }";
     $obj->views->getActive->map = 'function(doc) { if (doc.status == "active") {  emit(doc._id, doc); } };';
     $obj->views->getSuspended->map = 'function(doc) { if (doc.status == "suspended") {  emit(doc._id, doc); } };';
     $obj->views->getScrapeRequired->map = "function(doc) {   emit(doc.abn, doc); };";
     $obj->views->showNamesABNs->map = "function(doc) {   emit(doc._id, {name: doc.name, abn: doc.abn}); };";
+    // http://stackoverflow.com/questions/646628/javascript-startswith
+    $obj->views->score->map = 'if(!String.prototype.startsWith){
+    String.prototype.startsWith = function (str) {
+        return !this.indexOf(str);
+    }
+}
+
+function(doc) {
+count = 0;
+for(var propName in doc) {
+      if(typeof(doc[propName]) != "undefined" && propName.startsWith("l")) {
+  	count++
+	}
+}
+  emit(doc._id,{name: doc.name, score:count});
+}';
 
     // allow safe updates (even if slightly slower due to extra: rev-detection check).
     return $db->save($obj, true);

--- a/schemas/agency.json.php
+++ b/schemas/agency.json.php
@@ -4,8 +4,8 @@
     "description" => "Representation of government agency and online transparency measures",
     "type" => "object",
     "properties" => Array(
-        "name" => Array("type" => "string", "required" => true, "description" => "Agency Name, most recent and broadest"),
-        "othernames" => Array("type" => "array", "required" => true, "description" => "Agency Names",
+        "name" => Array("type" => "string", "required" => true, "x-title"=> "Agency Name", "description" => "Agency Name, most recent and broadest"),
+        "othernames" => Array("type" => "array", "required" => true, "x-title" => "Agency Past/Other Names", "description" => "Agency Names",
             "items" => Array("type" => "string")),
     ),
     /*"org":{"type":"object",

file:b/score.php (new)
--- /dev/null
+++ b/score.php
@@ -1,1 +1,19 @@
+<?php
 
+include_once('include/common.inc.php');
+include_header();
+
+$db = $server->get_db('disclosr-agencies');
+
+try {
+    $rows = $db->get_view("score", "score")->rows;
+    //print_r($rows);
+    foreach ($rows as $row) {
+        echo $row->value->name." ".$row->value->score."<br>";
+    }
+} catch (SetteeRestClientException $e) {
+    setteErrorHandler($e);
+}
+
+include_footer();
+?>