Skip to content

Commit

Permalink
Merge pull request #3 from vericite/master
Browse files Browse the repository at this point in the history
Only cache score if it is a valid score >= 0
  • Loading branch information
Bryan Holladay committed Apr 1, 2016
2 parents 3c5d2af + 4c3dc15 commit 67457af
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -407,17 +407,20 @@ public int getReviewScore(String contentId, String assignmentRef, String userId)
if(contentId.equals(scoreResponse.getExternalContentId())){
score = scoreResponse.getScore();
}
Map<String, Map<String, Object[]>> userCacheMap = contentScoreCache.get(scoreResponse.getAssignment());
if(userCacheMap == null){
userCacheMap = new HashMap<String, Map<String, Object[]>>();
}
Map<String, Object[]> cacheMap = userCacheMap.get(scoreResponse.getUser());
if(cacheMap == null){
cacheMap = new HashMap<String, Object[]>();
//only cache the score if it is > 0
if(scoreResponse.getScore() != null && scoreResponse.getScore().intValue() >= 0){
Map<String, Map<String, Object[]>> userCacheMap = contentScoreCache.get(scoreResponse.getAssignment());
if(userCacheMap == null){
userCacheMap = new HashMap<String, Map<String, Object[]>>();
}
Map<String, Object[]> cacheMap = userCacheMap.get(scoreResponse.getUser());
if(cacheMap == null){
cacheMap = new HashMap<String, Object[]>();
}
cacheMap.put(scoreResponse.getExternalContentId(), new Object[]{scoreResponse.getScore(), new Date()});
userCacheMap.put(scoreResponse.getUser(), cacheMap);
contentScoreCache.put(scoreResponse.getAssignment(), userCacheMap);
}
cacheMap.put(scoreResponse.getExternalContentId(), new Object[]{scoreResponse.getScore(), new Date()});
userCacheMap.put(scoreResponse.getUser(), cacheMap);
contentScoreCache.put(scoreResponse.getAssignment(), userCacheMap);
}
}
if(score == null){
Expand Down

0 comments on commit 67457af

Please sign in to comment.