@Override
public void refresh(Collection<Refreshable> alreadyRefreshed) {
Date ts = new Date(0);
BasicDBObject query = new BasicDBObject();
query.put("deleted_at", new BasicDBObject("$gt", mongoTimestamp));
DBCursor cursor = collection.find(query);
while (cursor.hasNext()) {
Map<String,Object> user = (Map<String,Object>) cursor.next().toMap();
String userID = getID(user.get(mongoUserID), true);
Collection<List<String>> items = Lists.newArrayList();
List<String> item = Lists.newArrayList();
item.add(getID(user.get(mongoItemID), false));
item.add(Float.toString(getPreference(user.get(mongoPreference))));
items.add(item);
try {
refreshData(userID, items, false);
} catch (NoSuchUserException e) {
log.warn("No such user ID: {}", userID);
} catch (NoSuchItemException e) {
log.warn("No such items: {}", items);
}
if (ts.compareTo(getDate(user.get("created_at"))) < 0) {
ts = getDate(user.get("created_at"));
}
}
query = new BasicDBObject();
query.put("created_at", new BasicDBObject("$gt", mongoTimestamp));
cursor = collection.find(query);
while (cursor.hasNext()) {
Map<String,Object> user = (Map<String,Object>) cursor.next().toMap();
if (!user.containsKey("deleted_at")) {
String userID = getID(user.get(mongoUserID), true);
Collection<List<String>> items = Lists.newArrayList();
List<String> item = Lists.newArrayList();
item.add(getID(user.get(mongoItemID), false));