Skip to content

Instantly share code, notes, and snippets.

@joshsmith
Created November 6, 2010 23:56
Show Gist options
  • Save joshsmith/665824 to your computer and use it in GitHub Desktop.
Save joshsmith/665824 to your computer and use it in GitHub Desktop.
if($_SESSION['last_directed_edge_request'] < time() - 600) {
// Get 100 interest recommendations from Directed Edge
$de = new DirectedEdgeRest();
$item = "user".$uid;
$limit = 100;
$tags = "interest";
$recommendedInterests = $de->getRecommended($item, $tags, $limit);
$recommendedInterestsCount = count($recommendedInterests);
$_SESSION['recommended_interests_count'] = $recommendedInterestsCount;
if(is_null($recommendedInterests)) {
$recommendedInterestsCount = 0;
}
// Get 100 question recommendations from Directed Edge
$de = new DirectedEdgeRest();
$item = "user".$uid;
$limit = 100;
$tags = "question";
$recommendedQuestions = $de->getRecommended($item, $tags, $limit);
$recommendedQuestionsCount = count($recommendedQuestions);
$_SESSION['recommended_questions_count'] = $recommendedQuestionsCount;
if(is_null($recommendedQuestions)) {
$recommendedQuestionsCount = 0;
}
$_SESSION['last_directed_edge_request'] = time();
}
if(isset($_SESSION['recommended_interests_count'])) {
$recommendedInterestsCount = $_SESSION['recommended_interests_count'];
}
if(isset($_SESSION['recommended_questions_count'])) {
$recommendedQuestionsCount = $_SESSION['recommended_questions_count'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment