Loading Controllers/api/v2/feeds.php +3 −1 Original line number Original line Diff line number Diff line Loading @@ -17,7 +17,8 @@ class feeds implements Interfaces\Api '12h' => '7d', '12h' => '7d', '24h' => '7d', '24h' => '7d', '7d' => '30d', '7d' => '30d', '30d' => '1y' '30d' => '1y', '1y' => 'all' ]; ]; /** /** Loading Loading @@ -221,6 +222,7 @@ class feeds implements Interfaces\Api $from = $now - $periodsInSecs[$period]; $from = $now - $periodsInSecs[$period]; $opts['from_timestamp'] = $from * 1000; $opts['from_timestamp'] = $from * 1000; $opts['period'] = static::PERIOD_FALLBACK[$period]; $opts['period'] = static::PERIOD_FALLBACK[$period]; $opts['limit'] = $limit - $entities->count(); if (!$fallbackAt) { if (!$fallbackAt) { $fallbackAt = $from; $fallbackAt = $from; Loading Core/Feeds/Elastic/Repository.php +14 −17 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ class Repository '7d' => 604800, '7d' => 604800, '30d' => 2592000, '30d' => 2592000, '1y' => 31536000, '1y' => 31536000, 'all' => -1, ]; ]; /** @var ElasticsearchClient */ /** @var ElasticsearchClient */ Loading Loading @@ -265,7 +266,7 @@ class Repository $timestampUpperBounds = []; // LTE $timestampUpperBounds = []; // LTE $timestampLowerBounds = []; // GT $timestampLowerBounds = []; // GT if ($algorithm->isTimestampConstrain()) { if ($algorithm->isTimestampConstrain() && static::PERIODS[$opts['period']] > -1) { $timestampLowerBounds[] = (time() - static::PERIODS[$opts['period']]) * 1000; $timestampLowerBounds[] = (time() - static::PERIODS[$opts['period']]) * 1000; } } Loading Loading @@ -323,23 +324,19 @@ class Repository ]; ]; } } } elseif ($opts['hashtags']) { } elseif ($opts['hashtags']) { if ($opts['filter_hashtags'] || $algorithm instanceof SortingAlgorithms\Chronological) { if (!isset($body['query']['function_score']['query']['bool']['must'])) { if (!isset($body['query']['function_score']['query']['bool']['must'])) { $body['query']['function_score']['query']['bool']['must'] = []; $body['query']['function_score']['query']['bool']['must'] = []; } } $body['query']['function_score']['query']['bool']['must'][] = [ $body['query']['function_score']['query']['bool']['must'][] = [ 'terms' => [ 'multi_match' => [ 'tags' => $opts['hashtags'], 'query' => implode(' ', $opts['hashtags']), ], 'fields' => ['name^2', 'title^12', 'message^12', 'description^12', 'brief_description^8', 'username^8', 'tags^64'], ]; 'operator' => 'or', } else { 'minimum_should_match' => 1, $body['query']['function_score']['query']['bool']['must'][] = [ 'terms' => [ 'tags' => $opts['hashtags'], ], ], ]; ]; } $body['query']['function_score']['boost_mode'] = 'replace'; } } if ($opts['exclude']) { if ($opts['exclude']) { Loading Loading
Controllers/api/v2/feeds.php +3 −1 Original line number Original line Diff line number Diff line Loading @@ -17,7 +17,8 @@ class feeds implements Interfaces\Api '12h' => '7d', '12h' => '7d', '24h' => '7d', '24h' => '7d', '7d' => '30d', '7d' => '30d', '30d' => '1y' '30d' => '1y', '1y' => 'all' ]; ]; /** /** Loading Loading @@ -221,6 +222,7 @@ class feeds implements Interfaces\Api $from = $now - $periodsInSecs[$period]; $from = $now - $periodsInSecs[$period]; $opts['from_timestamp'] = $from * 1000; $opts['from_timestamp'] = $from * 1000; $opts['period'] = static::PERIOD_FALLBACK[$period]; $opts['period'] = static::PERIOD_FALLBACK[$period]; $opts['limit'] = $limit - $entities->count(); if (!$fallbackAt) { if (!$fallbackAt) { $fallbackAt = $from; $fallbackAt = $from; Loading
Core/Feeds/Elastic/Repository.php +14 −17 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ class Repository '7d' => 604800, '7d' => 604800, '30d' => 2592000, '30d' => 2592000, '1y' => 31536000, '1y' => 31536000, 'all' => -1, ]; ]; /** @var ElasticsearchClient */ /** @var ElasticsearchClient */ Loading Loading @@ -265,7 +266,7 @@ class Repository $timestampUpperBounds = []; // LTE $timestampUpperBounds = []; // LTE $timestampLowerBounds = []; // GT $timestampLowerBounds = []; // GT if ($algorithm->isTimestampConstrain()) { if ($algorithm->isTimestampConstrain() && static::PERIODS[$opts['period']] > -1) { $timestampLowerBounds[] = (time() - static::PERIODS[$opts['period']]) * 1000; $timestampLowerBounds[] = (time() - static::PERIODS[$opts['period']]) * 1000; } } Loading Loading @@ -323,23 +324,19 @@ class Repository ]; ]; } } } elseif ($opts['hashtags']) { } elseif ($opts['hashtags']) { if ($opts['filter_hashtags'] || $algorithm instanceof SortingAlgorithms\Chronological) { if (!isset($body['query']['function_score']['query']['bool']['must'])) { if (!isset($body['query']['function_score']['query']['bool']['must'])) { $body['query']['function_score']['query']['bool']['must'] = []; $body['query']['function_score']['query']['bool']['must'] = []; } } $body['query']['function_score']['query']['bool']['must'][] = [ $body['query']['function_score']['query']['bool']['must'][] = [ 'terms' => [ 'multi_match' => [ 'tags' => $opts['hashtags'], 'query' => implode(' ', $opts['hashtags']), ], 'fields' => ['name^2', 'title^12', 'message^12', 'description^12', 'brief_description^8', 'username^8', 'tags^64'], ]; 'operator' => 'or', } else { 'minimum_should_match' => 1, $body['query']['function_score']['query']['bool']['must'][] = [ 'terms' => [ 'tags' => $opts['hashtags'], ], ], ]; ]; } $body['query']['function_score']['boost_mode'] = 'replace'; } } if ($opts['exclude']) { if ($opts['exclude']) { Loading