GraphAware\Reco4PHP\Demo\Github\PenalizeTooMuchFollowers::buildQuery PHP Method

buildQuery() public method

public buildQuery ( GraphAware\Common\Type\NodeInterface $input, Recommendations $recommendations )
$input GraphAware\Common\Type\NodeInterface
$recommendations GraphAware\Reco4PHP\Result\Recommendations
    public function buildQuery(NodeInterface $input, Recommendations $recommendations)
    {
        $ids = [];
        foreach ($recommendations->getItems() as $recommendation) {
            $ids[] = $recommendation->item()->identity();
        }
        $query = 'UNWIND {ids} as id
        MATCH (n) WHERE id(n) = id
        RETURN id, size((n)<-[:FOLLOWS]-()) as followersCount';
        return Statement::create($query, ['ids' => $ids]);
    }
PenalizeTooMuchFollowers