You are viewing a single comment's thread from:

RE: SteemJ V0.3.1 has been released - Update #13

in #steemdev7 years ago (edited)

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?

Sort:  

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!

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.029
BTC 68237.15
ETH 3499.75
USDT 1.00
SBD 2.72