close

  
<p> 

function related_films(film_id, after) {
  
    var film_q = [{
      "id":   film_id,
      "name": null,
      "type": "/film/film",
      "initial_release_date": null,
      "sort": "initial_release_date",
      "starring": [{
        "actor": {
          "id": null,
          "name": null
        }
      }]
    }];
  
    var date_prop = "/film/film/initial_release_date";
    film_q[0][date_prop] = null;
    film_q[0].sort = date_prop;
        
    film_q[0].id = film_id;
    var film_info = acre.freebase.mqlread(film_q).result;
    film_info = film_info.length &amp;&amp; film_info[0];
    var all_actors = [];
    var all_actor_ids = [];
    
    var starring = film_info &amp;&amp; film_info.starring || [];
  
    for (var i=0; i=" : " 1 || film.id == film_id)
          related_films.push(film);
      }
      cursor = f.cursor;
    }
    console.log("Finished with ", related_films.length, " films and cursor: ", cursor);
      
    // first find common actors between these films, create maps
    // from actor-&gt;films
    var films_by_actor = {};    
    
    var important_film_index = 0;
    for (var i=0; i 1 || film.id == film_id) {
        var position_y = 1;
        if (film.id == film_id)
          position_y = 0;
        film.position = {x: important_film_index, 
                         y: position_y};
        important_film_index++;
      }
      
      for (var j=0; j y)
    return 1;
  
  return 0;
}

function add_positions(films, films_by_actor) {
  // the position in the initial list is a hint
  films = films.slice(0);
  films.sort(function(f1, f2) {
    if (f1.position &amp;&amp; f2.position)
      return compare(f1.position.y, f2.position.y);
    if (f1.position)
      return -1;
    if (f2.position)
      return 1;
    return 0;
  });
  var position_list = [];  // The primary actor for the position
  
  for (var i=0; i</p>

Comments

Hide