(feat) top feeds should be filter by created time

1 merge request!294WIP: epic/post-scheduler
Pipeline #77085347 failed with stages
in 4 minutes and 17 seconds
......@@ -29,10 +29,11 @@ class Repository
/**
* @param array $opts
* @param bool $filter_by_created_time
* @return \Generator|ScoredGuid[]
* @throws \Exception
*/
public function getList(array $opts = [])
public function getList(array $opts = [], bool $filter_by_time_created = true)
{
$opts = array_merge([
'offset' => 0,
......@@ -53,6 +54,7 @@ class Repository
'exclude_moderated' => false,
'moderation_reservations' => null,
'pinned_guids' => null,
'time_created_upper' => $filter_by_time_created ? time() : null,
], $opts);
if (!$opts['type']) {
......@@ -254,6 +256,21 @@ class Repository
];
}
// Filter by time created to cut out scheduled feeds
if ($opts['time_created_upper']) {
if (!isset($body['query']['function_score']['query']['bool']['must'])) {
$body['query']['function_score']['query']['bool']['must'] = [];
}
$body['query']['function_score']['query']['bool']['must'][] = [
'range' => [
'time_created' => [
'lte' => (int) $opts['time_created_upper'],
],
],
];
}
//
if ($opts['query']) {
$words = explode(' ', $opts['query']);
......
Markdown is supported
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