Skip to content

Instantly share code, notes, and snippets.

@gargoyle
Created October 24, 2012 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gargoyle/3945549 to your computer and use it in GitHub Desktop.
Save gargoyle/3945549 to your computer and use it in GitHub Desktop.
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