Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search between accounts #594

Closed
wants to merge 4 commits into from
Closed

Search between accounts #594

wants to merge 4 commits into from

Conversation

unldenis
Copy link
Contributor

#506
Using classes AccountSearchRequest & AccountSearchResponse it works correctly but returns only the first 21 users (the first request) that are searched.
Usage:

        new AccountSearchRequest("something to search").execute(client)
    	.thenAccept(response -> {
    		response.getUsers().forEach(System.out::println);
    	}).join();

So I created the AccountSearchTokenRequest class for requests with rank_token and page_token. But so the class is useless without AccountSearch with which you can get all the 'pages' of the requests with the list of the returned accounts.
Usage:

        AccountSearch as = new AccountSearch(client, "something to search");    
        System.out.println("Total pages: " + as.getTotalPages());
        for(int j = 0; j<as.getTotalPages(); j++) {
        	System.out.println("Page number " + as.getCurrentPageN());
        	as.getCurrentPage().getUsers().forEach(u->System.out.println(u.getUsername()));
        	as.nextPage();    	
        }

Copy link
Collaborator

@jvogit jvogit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for opening a PR.

I've left some comments for you to address, then I think it should be good to go after.


import lombok.Getter;

public class AccountSearch {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality is already made possible thru FeedIterators so there might not be enough reason to include this.

If you want you can provide an actions method to do a search in the search actions

import lombok.NonNull;

@AllArgsConstructor
public class AccountSearchRequest extends IGGetRequest<AccountSearchResponse> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change name to UsersSearchRequest (path is users/search/) to fit convention.

Also please combine the two requests together into one class. One can set the rank token and page token through a constructor if needed!

import lombok.Data;

@Data
public class AccountSearchResponse extends IGResponse {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name should be changed to UsersSearchResponse for convention.

@unldenis
Copy link
Contributor Author

another pr comes

@unldenis unldenis closed this Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants