You are viewing a single comment's thread from:
RE: SteemJ V0.3.1 has been released - Update #13
Hi @dez1337
I would like to retrieve all comments of a user. I came up with the following code:
List<CommentOperation> commentOperations = new ArrayList<>();
Map<Integer, AccountActivity> accountHistoryCL = steemApiWrapper.getAccountHistory("accountName", 9999, 9999);
for(AccountActivity activity : accountHistoryCL.values()){
if(activity.getOperations() instanceof CommentOperation){
CommentOperation commentOperation = (CommentOperation)activity.getOperations();
if(commentOperation.getAuthor().getAccountName().equalsIgnoreCase("accountName")){
commentOperations.add(commentOperation);
}
}
}
But this seem to also retrieve blog posts and other stuff?. Is there a better way to retrieve all comments of a specific account?
Hay @coinlend,
Thank your for your question :) Actually I think you already went for the solution with the best performance 👍
Depending on what you are exactly doing it could boost the performance a lot if you go for a datacollector/datapresenter architecture. The datacollector would periodically insert the comment operations in a db so on a request the presenter only needs to perform a sql query instead of pulling all operations from a steem node for every single request .
Hope that helps at least a bit 💪
Thanks, that helps!