Skip to content
Snippets Groups Projects
Commit 05d13d95 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #61844 : wip

parent 2bb97234
Branches
Tags
4 merge requests!2334Master,!2254Master,!2253Hotline master,!2251Hotline#61844 recuperation des enrichissements
Pipeline #2091 passed with stage
in 19 minutes and 49 seconds
......@@ -24,6 +24,24 @@ class Artevod_Metadatas_Collection {
}
public function mergeWith($other) {
$merge = new static();
array_walk($this->_metas,
function($value, $key) use($other, $merge)
{
if (!$other->has($key))
return;
$mine = explode(';', $value);
$theirs = explode(';', $other->get($key, ''));
if ($missing = array_diff($theirs, $mine))
$merge->add($key, implode(';', $missing));
});
return $merge;
}
public function add($key, $value) {
$this->_metas[$key] = $value;
}
......@@ -49,6 +67,26 @@ class Artevod_Metadatas_Collection {
public function count() {
return count($this->_metas);
}
public function first() {
return reset($this->_metas);
}
public function firstKey() {
return reset(array_keys($this->_metas));
}
public function last() {
return end($this->_metas);
}
public function lastKey() {
return end(array_keys($this->_metas));
}
}
......@@ -141,10 +179,13 @@ class Artevod_Metadatas {
$old_metas = new Artevod_Metadatas_Collection($old_metas);
echo "attaching " . $old_metas->count() . " old metadatas into " . $this->_db_name . "\n";
echo "extracting current metadatas\n";
$current_metas = $this->_extractFromCurrentDb();
echo "currently " . $current_metas->count() . " metadatas, starting comparison...\n";
echo "\ncurrently " . $current_metas->count() . " metadatas, starting comparison...\n";
$merge = $current_metas->mergeWith($old_metas);
echo "found " . $merge->count() . " albums with missing data\n";
echo "example : " . $merge->firstKey() . ' is missing ' . $merge->first() . "\n";
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment