OpenSpending csv updates
[contractdashboard.git] / exportData.csv.php
blob:a/exportData.csv.php -> blob:b/exportData.csv.php
--- a/exportData.csv.php
+++ b/exportData.csv.php
@@ -10,16 +10,18 @@
 foreach ($unspscresult->fetchAll() as $row) {
     $unspsc[$row['UNSPSC']] = $row['Title'];
 }
-
+/*SELECT count(*), extract("week" from "publishDate") as week,extract("year" from "publishDate") as year
+FROM contractnotice   
+where "childCN" is null group by week, year order by year, week*/
 $query = $conn->prepare('
-SELECT "CNID",contractnotice."agencyName",agency.abn as "agencyABN",
+SELECT "CNID",contractnotice."agencyName",agency_nametoabn.abn as "agencyABN",
 EXTRACT(EPOCH FROM "publishDate") as "publishDate",
 EXTRACT(EPOCH FROM "contractStart") as "contractStart",
 EXTRACT(EPOCH FROM "contractEnd") as "contractEnd",
 value,description,category,
 "supplierName",(case when "supplierABN" != 0 THEN "supplierABN"::text ELSE "supplierName" END) as supplierID,
 (\'https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN\'::text || "CNID"::text) as sourceURL 
-FROM contractnotice join agency on contractnotice."agencyName"=agency."agencyName"  
+FROM contractnotice join agency_nametoabn on contractnotice."agencyName"=agency_nametoabn."agencyName"  
 where "childCN" is null'
         , array(PDO::ATTR_CURSOR => PDO::FETCH_ORI_NEXT));
 $query->execute();