Skip to content

CDA-88 - Implements username regex filter for /users endpoint#1614

Merged
rma-bryson merged 9 commits intodevelopfrom
bugfix/CDA-88-add-username-filtering-for-users
Mar 4, 2026
Merged

CDA-88 - Implements username regex filter for /users endpoint#1614
rma-bryson merged 9 commits intodevelopfrom
bugfix/CDA-88-add-username-filtering-for-users

Conversation

@rma-bryson
Copy link
Collaborator

No description provided.

@rma-bryson rma-bryson requested a review from rma-rripken March 2, 2026 17:46
@OpenApiParam(allowEmptyValue = true, name = OFFICE,
description = "Show only users with active privileges in a given office."
+ Controllers.OFFICE_DESCRIPTION ),
@OpenApiParam(name = USERNAME,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If its a regex the parameter name should be username-regex or username-like or username-mask. username-regex seems the most explicit to me.

Also, look at any other regex parameter - the swagger desc should link to the regex doc page.

Copy link
Contributor

Choose a reason for hiding this comment

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

don't we consistently use "-like" for the regex fields? Probably makes sense here to do both. username and username-like, backend can easily turn the username into a regex that means "I mean this exactly."

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 username-like. I'd rather not have two parameters that do the same thing. If it takes a regex you can always pass in an exact match. Unless there is/was an existing parameter that we need to maintain support for.

rma-rripken
rma-rripken previously approved these changes Mar 2, 2026
.where(upper(vUserGroups.DB_OFFICE_ID).eq(upper(limitOffice)))
.and(vUserGroups.IS_MEMBER.eq("T")).asField().gt(1);

// Note: usernameRegex is not included in the cursor; apply it if present in current request
Copy link
Contributor

Choose a reason for hiding this comment

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

huh, if it's not in the cursor, how are we paginating through it? the value of next-page is supposed to be self contained.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Many end-points, maybe even more than half, of the end-points do not include all the query parameters in the next-page cursor. Not saying that its right not to include them all but that is where we are at right now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we make a list of which end-points could be fixed with regard to the next-page cursor?

Copy link
Collaborator Author

@rma-bryson rma-bryson Mar 2, 2026

Choose a reason for hiding this comment

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

upon closer inspection, Users does include the username query param in the next-page cursor. Removed those lines of code. Also added test coverage.

Copy link
Collaborator

@rma-rripken rma-rripken Mar 2, 2026

Choose a reason for hiding this comment

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

Look again. If it was in the cursor somewhere you'd be pulling it out of parts[] and your Users object would be passing it into encodeCursor. If its not in the cursor and you removed it from the query params in the paging test and your IT is still passing that tells me the IT isn't right or there aren't enough IT.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, so it includes the last username, but that is not the regex query param.

If we want it self-contained, then we should include the regex in the cursor, otherwise the regex query param needs to be included in each subsequent paging web requests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems like it belongs in the cursor rather than a query param. Updated to include it.

@rma-bryson rma-bryson force-pushed the bugfix/CDA-88-add-username-filtering-for-users branch 2 times, most recently from 98664d5 to 9b3fec8 Compare March 2, 2026 22:02
try (final Timer.Context ignored = markAndTime(GET_ALL)) {
DSLContext dsl = getDslContext(ctx);
String office = ctx.queryParam(OFFICE);
String username = ctx.queryParam(USERNAME_LIKE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

call the variable usernameRegex or something similar to help track what it holds

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated to usernameRegex

Copy link
Contributor

@MikeNeilson MikeNeilson left a comment

Choose a reason for hiding this comment

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

Good change with the new interface. Have a little nitpick on the formatting and documentation for future devs.


public interface PageCursor {
void decodeCursor(String cursor, String delimiter);
String encode(Base64.Encoder encoder, String delimiter);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a new line between things -- all kinda blurred into one method on first read. Maybe a short javadoc explaining expectations for each method. Might be obvious to us but not the new reader.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added line breaks and javadocs

@rma-bryson rma-bryson force-pushed the bugfix/CDA-88-add-username-filtering-for-users branch from 87089f4 to a7aeaba Compare March 4, 2026 17:36
@rma-bryson rma-bryson requested a review from MikeNeilson March 4, 2026 17:36
@rma-bryson rma-bryson merged commit ea48e47 into develop Mar 4, 2026
9 checks passed
@rma-bryson rma-bryson deleted the bugfix/CDA-88-add-username-filtering-for-users branch March 4, 2026 18:39
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.

3 participants