Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add geometry filter for Event API#195

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Komzpa wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromcodex/add-flag-to-skip-geometry-in-event-api

Conversation

@Komzpa
Copy link
Member

@KomzpaKomzpa commentedJun 17, 2025
edited by coderabbitaibot
Loading

Summary

  • addGeometryFilterType enum
  • allow querying Event API without geometry
  • expose geometry filtering to Event API endpoints
  • adjust client, service, controller, and tests accordingly

Testing

  • ./gradlew test(fails: Unsupported class file major version 65)

https://chatgpt.com/codex/tasks/task_e_6851b525209c8324bc9b59ca253202a4

Summary by CodeRabbit

  • New Features

    • Added support for filtering events by geometry type when retrieving event lists and individual events. Users can now specify a geometry filter in relevant API requests.
  • Bug Fixes

    • Updated tests to ensure compatibility with the new geometry filter parameter in event retrieval APIs.

@coderabbitai
Copy link
Contributor

coderabbitaibot commentedJun 17, 2025
edited
Loading

Walkthrough

A new enum,GeometryFilterType, was introduced and integrated across the event API layers to enable geometry-based filtering of events. Method signatures in the controller, service, and client classes were updated to accept this parameter, defaulting toALL if unspecified. Corresponding tests were updated to reflect these changes.

Changes

File(s)Change Summary
src/main/java/io/kontur/disasterninja/dto/GeometryFilterType.javaAdded new enumGeometryFilterType with valuesALL andNONE.
src/main/java/io/kontur/disasterninja/client/EventApiClient.javaUpdatedgetEvents andgetEvent methods to accept and useGeometryFilterType as a query param.
src/main/java/io/kontur/disasterninja/controller/EventsController.javaController methods now acceptgeometryFilterType as a request parameter with defaultALL.
src/main/java/io/kontur/disasterninja/service/EventApiService.javaOverloaded/updated service methods to accept and forwardGeometryFilterType.
src/test/java/io/kontur/disasterninja/client/EventApiClientTest.javaUpdated tests to includegeometryFilterType in method calls and URI assertions.
src/test/java/io/kontur/disasterninja/service/EventApiServiceTest.javaUpdated mocks and verifications to includegeometryFilterType in relevant method calls.

Sequence Diagram(s)

sequenceDiagram    participant Client    participant Controller    participant Service    participant ApiClient    participant EventAPI    Client->>Controller: GET /events?geometryFilterType=ALL    Controller->>Service: getEvents(feed, bbox, geometryFilterType)    Service->>ApiClient: getEvents(feed, after, bbox, pageSize, sortOrder, geometryFilterType)    ApiClient->>EventAPI: GET /api/events?geometryFilterType=ALL    EventAPI-->>ApiClient: Event data    ApiClient-->>Service: Event data    Service-->>Controller: Event data    Controller-->>Client: Event data
Loading

Poem

In the warren of code, a filter appears,
Geometry shapes now lend us their ears.
From ALL to NONE, events we can find,
With enums and queries perfectly aligned.
Tests hop along, keeping bugs at bay—
A rabbit’s delight on a geometry day! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branchcodex/add-flag-to-skip-geometry-in-event-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on oursupport page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings togenerate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a.coderabbit.yaml file to the root of your repository.
  • Please see theconfiguration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🔭 Outside diff range comments (1)
src/main/java/io/kontur/disasterninja/client/EventApiClient.java (1)

104-118:geometryFilterType already defaulted – duplicateObjects.requireNonNullElse

Objects.requireNonNullElse is repeated in bothgetEvents andgetEvent. Extract the defaulting logic to a private helper or reuse the suggestion above to avoid duplication.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and betweencbf6075 and7c2080d.

📒 Files selected for processing (6)
  • src/main/java/io/kontur/disasterninja/client/EventApiClient.java (4 hunks)
  • src/main/java/io/kontur/disasterninja/controller/EventsController.java (3 hunks)
  • src/main/java/io/kontur/disasterninja/dto/GeometryFilterType.java (1 hunks)
  • src/main/java/io/kontur/disasterninja/service/EventApiService.java (3 hunks)
  • src/test/java/io/kontur/disasterninja/client/EventApiClientTest.java (7 hunks)
  • src/test/java/io/kontur/disasterninja/service/EventApiServiceTest.java (9 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (3)
src/test/java/io/kontur/disasterninja/service/EventApiServiceTest.java (1)

125-129:Tests correctly updated for new parameter

Mocks now include theGeometryFilterType.ALL argument ensuring the new API surface is fully covered.

src/test/java/io/kontur/disasterninja/client/EventApiClientTest.java (1)

50-55:URI assertions cover new query parameter

Regex expectations have been amended to assertgeometryFilterType=ALL; this safeguards against regressions.

src/main/java/io/kontur/disasterninja/service/EventApiService.java (1)

40-42:New overload keeps existing callers intact – well done
Delegating to the 3-arg variant withGeometryFilterType.ALL preserves backward compatibility and makes the change non-breaking.

Comment on lines +3 to +6
publicenumGeometryFilterType {
ALL,
NONE
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Add minimal Javadoc for public enum

Public enums form part of the external contract. Two-line Javadoc describing the intent of the enum and each value will greatly aid API consumers and generate clearer OpenAPI docs.

🤖 Prompt for AI Agents
In src/main/java/io/kontur/disasterninja/dto/GeometryFilterType.java aroundlines 3 to 6, add minimal Javadoc comments for the public enum and its values.Include a brief two-line description above the enum explaining its purpose, andadd a short comment for each enum constant describing what ALL and NONErepresent. This will improve API clarity and enhance generated OpenAPIdocumentation.

Comment on lines +51 to 59
publicOptional<EventApiSearchEventResponse>getEvents(StringeventApiFeed,OffsetDateTimeafter,
List<BigDecimal>bbox,intpageSize,
SortOrdersortOrder,GeometryFilterTypegeometryFilterType) {
UriComponentsBuilderuriBuilder =UriComponentsBuilder.fromUriString(EVENT_API_EVENT_LIST_URI);
uriBuilder.queryParam("episodeFilterType","NONE");
uriBuilder.queryParam("sortOrder",Objects.requireNonNullElse(sortOrder,"ASC"));
uriBuilder.queryParam("geometryFilterType",
Objects.requireNonNullElse(geometryFilterType,GeometryFilterType.ALL));

Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider null-safe defaulting outside the URI builder

Defaulting parameters up-front (before calling the URI builder) keeps the template construction cleaner and avoids repeatingObjects.requireNonNullElse. E.g.:

SortOrdereffectiveSort =sortOrder ==null ?SortOrder.ASC :sortOrder;GeometryFilterTypeeffectiveGeo =geometryFilterType ==null ?GeometryFilterType.ALL :geometryFilterType;uriBuilder.queryParam("sortOrder",effectiveSort)          .queryParam("geometryFilterType",effectiveGeo);

Reduces cognitive load and improves readability.

🤖 Prompt for AI Agents
In src/main/java/io/kontur/disasterninja/client/EventApiClient.java around lines51 to 59, the code uses Objects.requireNonNullElse directly inside the URIbuilder queryParam calls for sortOrder and geometryFilterType. To improvereadability and reduce repetition, assign default values to local variables forsortOrder and geometryFilterType before building the URI, then use thesevariables in the queryParam calls. This makes the URI construction cleaner andeasier to understand.

Comment on lines 55 to +57
uriBuilder.queryParam("episodeFilterType","NONE");
uriBuilder.queryParam("sortOrder",Objects.requireNonNullElse(sortOrder,"ASC"));
uriBuilder.queryParam("geometryFilterType",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Compile-time type mismatch insortOrder default

Objects.requireNonNullElse(sortOrder, "ASC") mixes theSortOrder enum with aString, which will not compile – the second argument must be of the same type as the first.

-uriBuilder.queryParam("sortOrder", Objects.requireNonNullElse(sortOrder, "ASC"));+uriBuilder.queryParam("sortOrder",+        Objects.requireNonNullElse(sortOrder, SortOrder.ASC));
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uriBuilder.queryParam("episodeFilterType","NONE");
uriBuilder.queryParam("sortOrder",Objects.requireNonNullElse(sortOrder,"ASC"));
uriBuilder.queryParam("geometryFilterType",
uriBuilder.queryParam("episodeFilterType","NONE");
uriBuilder.queryParam("sortOrder",
Objects.requireNonNullElse(sortOrder,SortOrder.ASC));
uriBuilder.queryParam("geometryFilterType",
🤖 Prompt for AI Agents
In src/main/java/io/kontur/disasterninja/client/EventApiClient.java around lines55 to 57, the call to Objects.requireNonNullElse uses a String "ASC" as thedefault for sortOrder, which is an enum type. Replace the String "ASC" with thecorresponding SortOrder enum constant (e.g., SortOrder.ASC) to ensure botharguments are of the same enum type and fix the compile-time type mismatch.

Comment on lines +60 to 66
List<BigDecimal>bbox,
@Parameter(description ="Geometry filter type",example ="ALL")
@RequestParam(defaultValue ="ALL")
GeometryFilterTypegeometryFilterType
) {
List<EventListDto>events =service.getEvents(feed,bbox);
List<EventListDto>events =service.getEvents(feed,bbox,geometryFilterType);
if (offset >=events.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Delegate paginationafter filtering in service layer

service.getEvents(feed, bbox, geometryFilterType) returns the full list which is then paginated in the controller.
Pullinglimit &offset into the service call would prevent unbounded list creation and potential OOM scenarios on feeds with large result sets.

Not a blocker for this PR but worth refactoring soon.

🤖 Prompt for AI Agents
In src/main/java/io/kontur/disasterninja/controller/EventsController.java aroundlines 60 to 66, the current code fetches the full event list fromservice.getEvents before applying pagination in the controller, which risks highmemory usage. Refactor by adding limit and offset parameters to theservice.getEvents method and move pagination logic into the service layer tofetch only the required subset of events, preventing unbounded list creation andpotential out-of-memory errors.

Comment on lines +80 to 82
publicEventDtogetEvent(UUIDeventId,Stringfeed,GeometryFilterTypegeometryFilterType) {
EventApiEventDtoevent =client.getEvent(eventId,feed,false,geometryFilterType);
if (event ==null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Duplicate null-safety concern for single-event retrieval
Apply the samenull check (orObjects.requireNonNull) here to prevent accidental NPEs and ensure consistent defaulting.

🤖 Prompt for AI Agents
In src/main/java/io/kontur/disasterninja/service/EventApiService.java aroundlines 80 to 82, add a null check or use Objects.requireNonNull on the result ofclient.getEvent to prevent potential NullPointerExceptions when retrieving asingle event. This will ensure consistent null-safety handling similar to otherparts of the code.

Comment on lines 88 to 90
publicList<EventEpisodeListDto>getEventEpisodes(UUIDeventId,Stringfeed) {
EventApiEventDtoevent =client.getEvent(eventId,feed,true);
EventApiEventDtoevent =client.getEvent(eventId,feed,true,GeometryFilterType.ALL);
if (event ==null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Expose geometry filtering for episode retrieval for API symmetry
getEventEpisodes hard-codesGeometryFilterType.ALL. If consumers may want to elide geometry, consider an overload mirroring the pattern used elsewhere:

publicList<EventEpisodeListDto>getEventEpisodes(UUIDeventId,Stringfeed,GeometryFilterTypegeometryFilterType) {returngetEventEpisodes(eventId,feed,geometryFilterType ==null ?GeometryFilterType.ALL :geometryFilterType);}

Keeps the current signature as a delegating helper, maintains backward compatibility, and provides full control to callers.

🤖 Prompt for AI Agents
In src/main/java/io/kontur/disasterninja/service/EventApiService.java aroundlines 88 to 90, the method getEventEpisodes currently hardcodesGeometryFilterType.ALL, limiting caller control. To fix this, add an overloadedgetEventEpisodes method that accepts a GeometryFilterType parameter, defaultingto ALL if null, and have the existing method delegate to this new overload. Thismaintains backward compatibility while exposing geometry filtering options tocallers.

Comment on lines +43 to 47
publicList<EventListDto>getEvents(Stringfeed,List<BigDecimal>bbox,GeometryFilterTypegeometryFilterType) {
OffsetDateTimeafter =OffsetDateTime.now().minusDays(4).truncatedTo(ChronoUnit.HOURS);
Optional<EventApiClient.EventApiSearchEventResponse>eventsResponse =client.getEvents(feed,after,bbox,
pageSize,EventApiClient.SortOrder.ASC);
pageSize,EventApiClient.SortOrder.ASC,geometryFilterType);

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add a null-safety guard forgeometryFilterType
External code can directly invoke this overload and passnull. Whennull reachesEventApiClient, query-string construction will either blow up or emitgeometryFilterType=null. Guard early:

+        if (geometryFilterType == null) {+            geometryFilterType = GeometryFilterType.ALL;+        }
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
publicList<EventListDto>getEvents(Stringfeed,List<BigDecimal>bbox,GeometryFilterTypegeometryFilterType) {
OffsetDateTimeafter =OffsetDateTime.now().minusDays(4).truncatedTo(ChronoUnit.HOURS);
Optional<EventApiClient.EventApiSearchEventResponse>eventsResponse =client.getEvents(feed,after,bbox,
pageSize,EventApiClient.SortOrder.ASC);
pageSize,EventApiClient.SortOrder.ASC,geometryFilterType);
publicList<EventListDto>getEvents(Stringfeed,List<BigDecimal>bbox,GeometryFilterTypegeometryFilterType) {
if (geometryFilterType ==null) {
geometryFilterType =GeometryFilterType.ALL;
}
OffsetDateTimeafter =OffsetDateTime.now().minusDays(4).truncatedTo(ChronoUnit.HOURS);
Optional<EventApiClient.EventApiSearchEventResponse>eventsResponse =client.getEvents(feed,after,bbox,
pageSize,EventApiClient.SortOrder.ASC,geometryFilterType);
// ...
}
🤖 Prompt for AI Agents
In src/main/java/io/kontur/disasterninja/service/EventApiService.java aroundlines 43 to 47, add a null check for the geometryFilterType parameter at thestart of the getEvents method. If geometryFilterType is null, assign it adefault non-null value before passing it to the client.getEvents call to preventnull pointer exceptions or invalid query-string construction.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@Komzpa

[8]ページ先頭

©2009-2025 Movatter.jp