Skip to content

Commit 8e7ad87

Browse files
committed
correctly detect non enriched activities and skip them during view rendering
1 parent 9333171 commit 8e7ad87

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/GetStream/StreamLaravel/Enrich.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ private function retrieveObjects($references)
5151
$with = $content_type_model->activityLazyLoading;
5252
}
5353
$fetched = $this->fromDb($content_type_model, array_keys($content_ids), $with);
54-
if (count($fetched) < count(array_keys($content_ids))) {
55-
$missing_ids = array_values(array_diff(array_keys($content_ids), array_keys($fetched)));
56-
$pretty_ids = var_export($missing_ids, true);
57-
throw new MissingDataException("Some data in this feed is not in the database: model: {$content_type} ids:{$pretty_ids}");
58-
}
5954
$objects[$content_type] = $fetched;
6055
}
6156
return $objects;
@@ -74,16 +69,18 @@ private function injectObjects(&$activities, $objects)
7469
{
7570
foreach ($activities as $key => $activity) {
7671
foreach ($this->fields as $field) {
77-
if (!array_key_exists($field, $activity))
72+
if (!isset($activity[$field]))
7873
continue;
7974
$value = $activity[$field];
8075
$reference = explode(':', $value);
81-
if (!array_key_exists($reference[0], $objects))
76+
if (!array_key_exists($reference[0], $objects)) {
8277
$activity->trackNotEnrichedField($reference[0], $reference[1]);
8378
continue;
84-
if (!array_key_exists($reference[1], $objects[$reference[0]]))
79+
}
80+
if (!array_key_exists($reference[1], $objects[$reference[0]])) {
8581
$activity->trackNotEnrichedField($reference[0], $reference[1]);
8682
continue;
83+
}
8784
$activities[$key][$field] = $objects[$reference[0]][$reference[1]];
8885
}
8986
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
@if (isset($prefix))
2-
@if (array_key_exists('activities', $activity))
3-
@include("aggregated_activity.{$prefix}_{$activity['verb']}", array('activity'=>$activity))
1+
@if ($activity->enriched())
2+
@if (isset($prefix))
3+
@if (array_key_exists('activities', $activity))
4+
@include("aggregated_activity.{$prefix}_{$activity['verb']}", array('activity'=>$activity))
5+
@else
6+
@include("/activity.{$prefix}_{$activity['verb']}", array('activity'=>$activity))
7+
@endif
48
@else
5-
@include("/activity.{$prefix}_{$activity['verb']}", array('activity'=>$activity))
9+
@if (array_key_exists('activities', $activity))
10+
@include("aggregated_activity.{$activity['verb']}", array('activity'=>$activity))
11+
@else
12+
@include("/activity.{$activity['verb']}", array('activity'=>$activity))
13+
@endif
614
@endif
715
@else
8-
@if (array_key_exists('activities', $activity))
9-
@include("aggregated_activity.{$activity['verb']}", array('activity'=>$activity))
10-
@else
11-
@include("/activity.{$activity['verb']}", array('activity'=>$activity))
12-
@endif
16+
{{ ''; Log::warning('The activity could not be rendered, the following field/refs could not be enriched:', $activity->getNotEnrichedData()); }}
1317
@endif

0 commit comments

Comments
 (0)