Created
September 2, 2014 15:38
-
-
Save adridev/463f70e292c6caf5af25 to your computer and use it in GitHub Desktop.
Algo improved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$questions = array_values($questions); | |
foreach ($questions as $k => $q) { | |
$key = (string) 'q' . (++$k); | |
$questionMapping[$key] = $q; | |
} | |
$template = " | |
MATCH | |
(u:User)-[:RATES]->(q:Question) | |
WHERE | |
q.qnoow_id IN [ "; | |
foreach ($questionMapping as $k => $q) { | |
$template .= "{" . $k . "}, "; | |
} | |
$template = rtrim(trim($template), ","); | |
$template .= " ] | |
AND NOT u.qnoow_id = " . $id . " | |
RETURN | |
u.qnoow_id AS u;"; | |
//Create the Neo4j template object | |
$neoQuery = new Query( | |
$this->client, | |
$template, | |
$questionMapping | |
); | |
try { | |
$result = $neoQuery->getResultSet(); | |
} catch (\Exception $e) { | |
throw $e; | |
} | |
//TODO: check that the execution and integration of this function actually works :/ | |
//TODO: enqueue the calculation of these matching instead of calculating them in a loop (launch workers?) I didn't do it myself because I don't really know how the queues work :( | |
foreach ($result as $row) { | |
$this->getMatchingBetweenTwoUsersBasedOnAnswers($id, $row['u']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment