I need to count all likes of a user that has happened in last 7 days.
Only way i can think of, is to iterate all spaces, pages, comments and count likes, then check the creationDate and creator. However, as systems grow bigger, this could seriously become an performance issue? I have thought of using direct access to database, but i would like to do it with API.
Is there any other ways? Have i missed some manager?
Community moderators have prevented the ability to post new answers.
I ended up doing it with plain API calls.
SpaceManager.getAllSpaces()->
PageManager.getPages(space,false)->
LikeManager.getLikes(page)
Recursively(LikeManager.getLikes(obj.getComments))
I used recursion to get likes of all comments and comments on comments on comments..
for(Space space : spaceManager.getAllSpaces()) { List<Page> pageList = pageManager.getPages(space,false); for(Page page : pageList) { List<Like> likeList = likeManager.getLikes(page); List<Like> commentLikeList = getCommentLikesWithRecursion(new ArrayList<Like>(), page.getComments()); commentLikeList.addAll(likeList); } } private List<Like> getCommentLikesWithRecursion(List<Like> likeList, List<Comment> commentList) { for(Comment comment : commentList) { likeList.addAll(likeManager.getLikes(comment)); getCommentLikesWithRecursion(likeList, comment.getComments()); } return likeList; }
This worked for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.