Created
October 24, 2012 11:25
-
-
Save paul-court/3945549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function run() | |
{ | |
$handler = new Place_handler(); | |
$collection = $handler->getCollection(); | |
$cursor = $handler->find(); | |
$total = $cursor->count(); | |
$count = 0; | |
foreach ($cursor as $doc) { | |
$count++; | |
// Remove stray field (it's missing the r from franchisee. | |
if (isset($doc['fanchiseeProfile'])) { | |
unset($doc['fanchiseeProfile']); | |
} | |
// Standardise status | |
$doc['status'] = Mongo_base::STATUS_DISABLED; | |
foreach ($doc['flags'] as $flag) { | |
if (isset($flag['name']) && ($flag['name'] == 'Active')) { | |
if (!isset($flag['value']) || ($flag['value'] == true)) { | |
$doc['status'] = Mongo_base::STATUS_LIVE; | |
} | |
} | |
} | |
// Save the updated doc | |
$collection->save($doc); | |
} | |
$this->outputText("Processed " . $count . " of " . $total . " places."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment