Commit c03f1358 authored by Ben's avatar Ben
Browse files

Added all to feed @edgebal

parent edd3f589
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,9 @@ class container implements Interfaces\Api
            case 'blogs':
            case 'blogs':
                $type = 'object:blog';
                $type = 'object:blog';
                break;
                break;
            case 'all':
                $type = 'all';
                break;
        }
        }


        //
        //
+1 −0
Original line number Original line Diff line number Diff line
@@ -95,6 +95,7 @@ class Manager
            'filter_hashtags' => false,
            'filter_hashtags' => false,
            'pinned_guids' => null,
            'pinned_guids' => null,
            'as_activities' => false,
            'as_activities' => false,
            'exclude' => null,
        ], $opts);
        ], $opts);


        if (isset($opts['query']) && $opts['query']) {
        if (isset($opts['query']) && $opts['query']) {
+22 −5
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ class Repository
            'exclude_moderated' => false,
            'exclude_moderated' => false,
            'moderation_reservations' => null,
            'moderation_reservations' => null,
            'pinned_guids' => null,
            'pinned_guids' => null,
            'exclude' => null,
        ], $opts);
        ], $opts);


        if (!$opts['type']) {
        if (!$opts['type']) {
@@ -67,6 +68,8 @@ class Repository
            throw new \Exception('Unsupported period');
            throw new \Exception('Unsupported period');
        }
        }


        $type = $opts['type'];

        $body = [
        $body = [
            '_source' => array_unique([
            '_source' => array_unique([
                'guid',
                'guid',
@@ -75,7 +78,7 @@ class Repository
                'time_created',
                'time_created',
                'access_id',
                'access_id',
                'moderator_guid',
                'moderator_guid',
                $this->getSourceField($opts['type']),
                $this->getSourceField($type),
            ]),
            ]),
            'query' => [
            'query' => [
                'function_score' => [
                'function_score' => [
@@ -98,7 +101,7 @@ class Repository
            'sort' => [],
            'sort' => [],
        ];
        ];


        /*if ($opts['type'] === 'group' && false) {
        /*if ($type === 'group' && false) {
            if (!isset($body['query']['function_score']['query']['bool']['must_not'])) {
            if (!isset($body['query']['function_score']['query']['bool']['must_not'])) {
                $body['query']['function_score']['query']['bool']['must_not'] = [];
                $body['query']['function_score']['query']['bool']['must_not'] = [];
            }
            }
@@ -107,7 +110,7 @@ class Repository
                    'access_id' => ['0', '1', '2'],
                    'access_id' => ['0', '1', '2'],
                ],
                ],
            ];
            ];
        } elseif ($opts['type'] === 'user') {
        } elseif ($type === 'user') {
            $body['query']['function_score']['query']['bool']['must'][] = [
            $body['query']['function_score']['query']['bool']['must'][] = [
                'term' => [
                'term' => [
                    'access_id' => '2',
                    'access_id' => '2',
@@ -236,7 +239,7 @@ class Repository
            }
            }
        }
        }


        if ($opts['type'] !== 'group' && $opts['access_id'] !== null) {
        if ($type !== 'group' && $opts['access_id'] !== null) {
            $body['query']['function_score']['query']['bool']['must'][] = [
            $body['query']['function_score']['query']['bool']['must'][] = [
                'terms' => [
                'terms' => [
                    'access_id' => Text::buildArray($opts['access_id']),
                    'access_id' => Text::buildArray($opts['access_id']),
@@ -294,6 +297,14 @@ class Repository
            }
            }
        }
        }


        if ($opts['exclude']) {
            $body['query']['function_score']['query']['bool']['must_not'][] = [
                'terms' => [
                    'guid' => Text::buildArray($opts['exclude']),
                ],
            ];
        }



        // firehose options
        // firehose options


@@ -338,9 +349,15 @@ class Repository


        //
        //


        $esType = $opts['type'];

        if ($esType === 'all') {
            $esType = 'object:image,object:video,object:blog';
        }

        $query = [
        $query = [
            'index' => $this->index,
            'index' => $this->index,
            'type' => $opts['type'],
            'type' => $esType,
            'body' => $body,
            'body' => $body,
            'size' => $opts['limit'],
            'size' => $opts['limit'],
            'from' => $opts['offset'],
            'from' => $opts['offset'],