Author: mcantelon
Date: Wed Jan 4 14:19:01 2012
New Revision: 10556
Log:
Added CLI option to import tool to periodically output number of rows processed.
Modified:
trunk/lib/task/csvImportTask.class.php
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Wed Jan 4 13:59:06 2012
(r10555)
+++ trunk/lib/task/csvImportTask.class.php Wed Jan 4 14:19:01 2012
(r10556)
@@ -39,6 +39,10 @@
new sfCommandArgument('filename', sfCommandArgument::REQUIRED, 'The
input file (csv format).')
));
+ $this->addOptions(array(
+ new sfCommandOption('rows-until-update', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Output total rows imported every n rows.')
+ ));
+
$this->namespace = 'csv';
$this->name = 'import';
$this->briefDescription = 'Import csv data';
@@ -53,6 +57,12 @@
*/
public function execute($arguments = array(), $options = array())
{
+
+ if ($options['rows-until-update'] &&
!is_numeric($options['rows-until-update']))
+ {
+ throw new sfException('rows-until-update must be an integer');
+ }
+
$databaseManager = new sfDatabaseManager($this->configuration);
$conn = $databaseManager->getDatabase('propel')->getConnection();
@@ -323,9 +333,18 @@
}
}
}
+ if ($options = $self->getStatus('options'))
+ {
+ if ($options['rows-until-update'] && !(($self->getStatus('rows') +
1) % $options['rows-until-update']))
+ {
+ print "\n". ($self->getStatus('rows') + 1) ." rows processed.\n";
+ }
+ }
}
));
+ $import->setStatus('options', $options);
+
$import->addColumnHandler('levelOfDescription', function(&$self, $data)
{
$self->informationObject->setLevelOfDescriptionByName($data);
@@ -372,7 +391,8 @@
$import->addColumnHandler('COPYRIGHT_STATUS', function(&$self, $data)
{
- if (trim($data)) {
+ if (trim($data))
+ {
$self->rowStatusVars['copyrightStatusOrRightsholder'] = $data;
}
});
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.