Skip to content

Commit 5beaa16

Browse files
committed
Refactored DHS data import.
Removed data from surveys and imported subnational data in data collection: this way we can compute the data we are interested in and set it into the surveys.
1 parent fe06cb6 commit 5beaa16

File tree

3 files changed

+48
-51
lines changed

3 files changed

+48
-51
lines changed

.idea/workspace.xml

+31-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

batch/DHS.php

+13-10
Original file line numberDiff line numberDiff line change
@@ -1084,9 +1084,9 @@ public function InitSurveys()
10841084
//
10851085
// Load survey data.
10861086
//
1087-
$data_points = $this->loadSurveyData( $line[ 'SurveyId' ] );
1088-
if( count( $data_points ) )
1089-
$document[ kTAG_DATA ] = $data_points;
1087+
// $data_points = $this->loadSurveyData( $line[ 'SurveyId' ] );
1088+
// if( count( $data_points ) )
1089+
// $document[ kTAG_DATA ] = $data_points;
10901090

10911091
//
10921092
// Save document.
@@ -1135,9 +1135,9 @@ public function InitSurveys()
11351135
*==================================================================================*/
11361136

11371137
/**
1138-
* <h4>Initialise surveys.</h4>
1138+
* <h4>Initialise survey data.</h4>
11391139
*
1140-
* This method will load the surveys.
1140+
* This method will load the surveys data at sub-national level.
11411141
*/
11421142
public function InitData()
11431143
{
@@ -1146,8 +1146,8 @@ public function InitData()
11461146
//
11471147
$collection = $this->mDatabase->NewDataCollection();
11481148
$page = 1;
1149-
$lines = 100;
1150-
$url = self::kDHS_URL_DATA . "&page=$page&perpage=$lines";
1149+
$lines = 600;
1150+
$url = self::kDHS_URL_DATA . "subnational?f=json&page=$page&perpage=$lines";
11511151

11521152
//
11531153
// Read data.
@@ -1185,8 +1185,11 @@ public function InitData()
11851185
//
11861186
// Set identifiers.
11871187
//
1188-
$document[ $collection->KeyOffset() ]
1189-
= $line[ 'SurveyId' ] . ':' . $line[ 'DataId' ];
1188+
$document[ $collection->KeyOffset() ] = (int)$line[ 'DataId' ];
1189+
// $document[ $collection->KeyOffset() ]
1190+
// = $line[ 'SurveyId' ] . ':'
1191+
// . $line[ 'RegionId' ] . ':'
1192+
// . $line[ 'DataId' ];
11901193

11911194
//
11921195
// Set other data.
@@ -1252,7 +1255,7 @@ public function InitData()
12521255
// Get next.
12531256
//
12541257
$page++;
1255-
$url = self::kDHS_URL_DATA . "&page=$page&perpage=$lines";
1258+
$url = self::kDHS_URL_DATA . "subnational?f=json&page=$page&perpage=$lines";
12561259
$retries = self::kRETRIES;
12571260
while( $retries-- )
12581261
{

batch/InitDHS.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Initialisation definition.
1919
*/
2020
define( 'doINIT', TRUE );
21-
define( 'kENGINE', 'ARANGO' );
21+
define( 'kENGINE', 'MONGO' );
2222

2323
/*
2424
* Global includes.
@@ -143,9 +143,9 @@
143143
//
144144
// Initialise DHS data.
145145
//
146-
//echo( "- Initialising DHS data: " );
147-
//$dhs->InitData();
148-
//echo( " Done.\n" );
146+
echo( "- Initialising DHS data: " );
147+
$dhs->InitData();
148+
echo( " Done.\n" );
149149

150150

151151
?>

0 commit comments

Comments
 (0)