Prioritize relative ids for episodes, as external ids reported from backends is often incorrect for episodes.
This commit is contained in:
@@ -527,7 +527,19 @@ final class DirectMapper implements ImportInterface
|
||||
return $entity->id;
|
||||
}
|
||||
|
||||
foreach ([...$entity->getRelativePointers(), ...$entity->getPointers()] as $key) {
|
||||
// -- Prioritize relative ids for episodes, External ids are often incorrect for episodes.
|
||||
if (true === $entity->isEpisode()) {
|
||||
foreach ($entity->getRelativePointers() as $key) {
|
||||
$lookup = $key . '/' . $entity->type;
|
||||
if (null !== ($this->pointers[$lookup] ?? null)) {
|
||||
return $this->pointers[$lookup];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -- look up movies based on guid.
|
||||
// -- if episode didn't have any match using relative id then fallback to external ids.
|
||||
foreach ($entity->getPointers() as $key) {
|
||||
$lookup = $key . '/' . $entity->type;
|
||||
if (null !== ($this->pointers[$lookup] ?? null)) {
|
||||
return $this->pointers[$lookup];
|
||||
|
||||
@@ -451,7 +451,19 @@ final class MemoryMapper implements ImportInterface
|
||||
return self::GUID . $entity->id;
|
||||
}
|
||||
|
||||
foreach ([...$entity->getRelativePointers(), ...$entity->getPointers()] as $key) {
|
||||
// -- Prioritize relative ids for episodes, External ids are often incorrect for episodes.
|
||||
if (true === $entity->isEpisode()) {
|
||||
foreach ($entity->getRelativePointers() as $key) {
|
||||
$lookup = $key . '/' . $entity->type;
|
||||
if (null !== ($this->pointers[$lookup] ?? null)) {
|
||||
return $this->pointers[$lookup];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -- look up movies based on guid.
|
||||
// -- if episode didn't have any match using relative id then fallback to external ids.
|
||||
foreach ($entity->getPointers() as $key) {
|
||||
$lookup = $key . '/' . $entity->type;
|
||||
if (null !== ($this->pointers[$lookup] ?? null)) {
|
||||
return $this->pointers[$lookup];
|
||||
|
||||
@@ -465,15 +465,6 @@ final class PDOAdapter implements StorageInterface
|
||||
'type' => $entity->type,
|
||||
];
|
||||
|
||||
foreach ($entity->getGuids() as $key => $val) {
|
||||
if (empty($val)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$guids[] = "JSON_EXTRACT(" . iFace::COLUMN_GUIDS . ",'$.{$key}') = :g_{$key}";
|
||||
$cond['g_' . $key] = $val;
|
||||
}
|
||||
|
||||
$sqlEpisode = '';
|
||||
|
||||
if (true === $entity->isEpisode()) {
|
||||
@@ -492,6 +483,15 @@ final class PDOAdapter implements StorageInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($entity->getGuids() as $key => $val) {
|
||||
if (empty($val)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$guids[] = "JSON_EXTRACT(" . iFace::COLUMN_GUIDS . ",'$.{$key}') = :g_{$key}";
|
||||
$cond['g_' . $key] = $val;
|
||||
}
|
||||
|
||||
if (empty($guids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user