Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117806335
D5148.1775273864.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D5148.1775273864.diff
View Options
diff --git a/src/app/DataMigrator/Engine.php b/src/app/DataMigrator/Engine.php
--- a/src/app/DataMigrator/Engine.php
+++ b/src/app/DataMigrator/Engine.php
@@ -179,12 +179,16 @@
$count = 0;
$itemCount = 0;
+ $startTime = 0;
$async = empty($this->options['sync']);
// Fetch items from the source
$this->exporter->fetchItemList(
$folder,
- function ($item_or_set) use (&$count, &$itemCount, $async) {
+ function ($item_or_set) use (&$count, &$itemCount, &$startTime, $async) {
+ if (!$startTime) {
+ $startTime = time();
+ }
if ($item_or_set instanceof ItemSet) {
$itemCount += count($item_or_set->items);
} else {
@@ -199,6 +203,8 @@
}
$count++;
} else {
+ $rate = (double)$itemCount / max((time() - $startTime), 1);
+ $this->progress(sprintf(" Item Progress [%d] %f items/s", $itemCount, $rate));
if ($item_or_set instanceof ItemSet) {
$this->processItemSet($item_or_set);
} else {
@@ -208,6 +214,7 @@
},
$this->importer
);
+ $this->progressComplete();
$this->debug("Migrated $itemCount items");
if ($count) {
@@ -292,6 +299,29 @@
}
}
+ /**
+ * Print progress information
+ *
+ * This just rewrite the curent line
+ */
+ public function progress($line)
+ {
+ if (!empty($this->options['stdout'])) {
+ $output = new \Symfony\Component\Console\Output\ConsoleOutput();
+ $output->write("\r$line");
+ }
+ }
+
+ /**
+ * Move to a new line after progress output
+ */
+ public function progressComplete() {
+ if (!empty($this->options['stdout'])) {
+ $output = new \Symfony\Component\Console\Output\ConsoleOutput();
+ $output->writeln("");
+ }
+ }
+
/**
* Get migration option value.
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 4, 3:37 AM (11 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18827928
Default Alt Text
D5148.1775273864.diff (2 KB)
Attached To
Mode
D5148: Progress reporting
Attached
Detach File
Event Timeline