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

Issue searching audience segments with name starting from the search term #220

Open
AndreiLosikTR opened this issue Apr 14, 2021 · 1 comment
Assignees

Comments

@AndreiLosikTR
Copy link

Hi All,

I'm trying to request all audience segments which start from "PA - " but the API looks like returns audience segments with the search term not only at the beginning of the name, but also in any part of the name.

This is how my code looks like:


    @Override
    public List<AudienceSegment> findAllPAs() {
        StatementBuilder statementBuilder =
                new StatementBuilder()
                        .where("name LIKE 'PA - %' and type = 'FIRST_PARTY'")
                        .orderBy("id ASC");
        return findAllAudienceSegmentsByStatement(statementBuilder, StatementBuilder.SUGGESTED_PAGE_LIMIT);
    }

private List<AudienceSegment> findAllAudienceSegmentsByStatement(StatementBuilder statement, int limit) {
        statement.limit(limit);
        List<AudienceSegment> segments = new ArrayList<>();
        int totalResultSetSize = 0;

        do {
            AudienceSegmentPage page;
            try {
                page = audienceSegmentService.getAudienceSegmentsByStatement(statement.toStatement());
            } catch (RemoteException re) {
                throw new RuntimeException(re);
            }

            if (page.getResults() != null) {
                totalResultSetSize = page.getTotalResultSetSize();
                segments.addAll(Arrays.asList(page.getResults()));
            }

            statement.increaseOffsetBy(limit);
        } while (statement.getOffset() < totalResultSetSize);

        return segments;
    }

Thanks,
Andrei

@nwbirnie
Copy link
Contributor

@christopherseeley PTAL

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

No branches or pull requests

3 participants