Confluence Api, how to count likes of user in last 7 days

RikuK March 10, 2014

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?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
RikuK March 11, 2014

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.

TAGS
AUG Leaders

Atlassian Community Events