@Override
  public double[] createDistancesVector(Long myUserId) {
    int totalNoUsers = countAllUsers().intValue() + 1;
    double[] distances = new double[totalNoUsers];
    Iterable<User> users = userRepository.findAll();
    Iterator<User> iterator = users.iterator();
    double[] myRatings = createActivityVector(myUserId);

    while (iterator.hasNext()) {
      User u = iterator.next();
      Long userId = u.getId();
      if (userId != myUserId) {
        double[] userRatings = createActivityVector(userId);
        if (RecommendationUtils.intersect(myRatings, userRatings)) {
          distances[userId.intValue()] =
              RecommendationUtils.cosineSimilarity(myRatings, userRatings);
        } else {
          distances[userId.intValue()] = Double.MIN_VALUE;
        }
      } else {
        distances[userId.intValue()] = Double.MIN_VALUE;
      }
    }

    return distances;
  }
 @Override
 public Long countAllUsers() {
   return userRepository.count();
 }