Skip to content

Commit

Permalink
Merge pull request #30 from Xoshbin/fix_wrong_source_id
Browse files Browse the repository at this point in the history
fix the generated wrong source_id value in the recommendations table
  • Loading branch information
umutphp authored Feb 4, 2024
2 parents 69b17b5 + c16a57a commit 2a19d38
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/HasRecommendation.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ public static function calculateRecommendations($data, $dataCount)
foreach ($dataCartesianRanks as $data1 => $data) {
arsort($data);

$key = key($dataGroup);

$data = array_slice($data, 0, $dataCount, true);
$recommendations[$data1] = $data;
$recommendations[$key] = $data;
}

return $recommendations;
Expand Down Expand Up @@ -301,7 +303,7 @@ public static function calculateSimilarityMatrix($models, $config): array
public function getRecommendations($name)
{
$config = $this->getRecommendationConfig()[$name] ?? null;
$model=$config['recommendation_data_field_type']??self::class;
$model = $config['recommendation_data_field_type'] ?? self::class;

if ($config === null) {
return [];
Expand All @@ -313,7 +315,7 @@ public function getRecommendations($name)
->where('source_id', $this->id)
->get();


$return = $model::query()->whereIn('id', $recommendations->pluck('target_id'))->get();

$order = $config['recommendation_order'] ?? config('laravel_model_recommendation.recommendation_count');
Expand Down

0 comments on commit 2a19d38

Please sign in to comment.