Skip to content

revamp home api #1307

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

Merged
merged 5 commits into from
May 8, 2025
Merged

Conversation

nikhilsinhaparseable
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable commented May 6, 2025

update the implementation of /api/prism/v1/home
remove titles of alerts, dashboards, correlations, filters from home api

updated response -

{
    "alerts_info": {
        "total": 0,
        "silenced": 0,
        "resolved": 0,
        "triggered": 0,
        "low": 0,
        "medium": 0,
        "high": 0,
        "critical": 0
    },
    "stats_details": [
        {
            "date": "2025-04-30",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-01",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-02",
            "events": 3866860,
            "ingestion_size": 5260602290,
            "storage_size": 736510108
        },
        {
            "date": "2025-05-03",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-04",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-05",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-06",
            "events": 2027400,
            "ingestion_size": 2757834546,
            "storage_size": 384782870
        }
    ],
    "datasets": [
        {
            "title": "test15",
            "dataset_type": "Logs"
        }
    ]
}

add another api to be called from prism
/api/prism/v1/home/search

server sends title and id of alerts, dashboards, correlations, filters

{
    "alerts": [],
    "correlations": [],
    "dashboards": [],
    "filters": [
        {
            "title": "body not null",
            "id": "e71d1affa4ad72136e03092a717a4b0e0c3fd6d643a09572ad65e1748a5c2df8"
        },
        {
            "title": "select *",
            "id": "6fe16f99b05566d7d4a598a7f0fa2604379d75164cdda5657c7fdbf61e54a555"
        }
    ]
}

update datasets api -
update readers priviledge - add GetRetention action remove distinct values from datasets api
prism to call the query apis directly for p_src_ip and p_user_agent

Summary by CodeRabbit

  • New Features

    • Introduced a new /home/search endpoint, providing search-related metadata for alerts, correlations, dashboards, filters, and datasets.
  • Improvements

    • Enhanced the /home endpoint to support multiple routes, allowing for more flexible data retrieval under the /home prefix.
    • The "Reader" role now includes permission to view retention settings.
  • Refactor

    • Separated home page data from search metadata, resulting in clearer and more maintainable responses.
  • Bug Fixes

    • Removed distinct source data (such as IPs and user agents) from dataset responses to streamline output.

update the implementation of `/api/prism/v1/home`
remove titles of alerts, dashboards, correlations, filters from home api

updated response -
```
{
    "alerts_info": {
        "total": 0,
        "silenced": 0,
        "resolved": 0,
        "triggered": 0,
        "low": 0,
        "medium": 0,
        "high": 0,
        "critical": 0
    },
    "stats_details": [
        {
            "date": "2025-04-30",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-01",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-02",
            "events": 3866860,
            "ingestion_size": 5260602290,
            "storage_size": 736510108
        },
        {
            "date": "2025-05-03",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-04",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-05",
            "events": 0,
            "ingestion_size": 0,
            "storage_size": 0
        },
        {
            "date": "2025-05-06",
            "events": 2027400,
            "ingestion_size": 2757834546,
            "storage_size": 384782870
        }
    ],
    "datasets": [
        {
            "title": "test15",
            "dataset_type": "Logs"
        }
    ]
}
```

add another api to be called from prism
`/api/prism/v1/home/search`

server sends title and id of alerts, dashboards, correlations, filters

```
{
    "alerts": [],
    "correlations": [],
    "dashboards": [],
    "filters": [
        {
            "title": "body not null",
            "id": "e71d1affa4ad72136e03092a717a4b0e0c3fd6d643a09572ad65e1748a5c2df8"
        },
        {
            "title": "select *",
            "id": "6fe16f99b05566d7d4a598a7f0fa2604379d75164cdda5657c7fdbf61e54a555"
        }
    ]
}
```

update datasets api -
update readers priviledge - add `GetRetention` action
remove distinct values from datasets api
prism to call the query apis directly for p_src_ip and p_user_agent
Copy link

coderabbitai bot commented May 6, 2025

"""

Walkthrough

This change splits the /home API endpoint into a scope supporting both /home and /home/search routes, each with its own handler and response structure. The home response is simplified, with search-related metadata now provided by a new dedicated endpoint. Unrelated distinct source field logic is removed from dataset responses, and reader role permissions are updated.

Changes

File(s) Change Summary
src/handlers/http/modal/server.rs Refactored get_prism_home to return a Scope at /home with two GET routes: /home and /home/search, each routed to separate handler functions.
src/handlers/http/prism_home.rs Added new async handler home_search for /home/search, extracting session key and returning search metadata. Updated imports.
src/prism/home/mod.rs Removed StreamInfo struct and several fields from HomeResponse; introduced HomeSearchResponse struct and generate_home_search_response function; updated helper functions to accept query filtering; extended error enum.
src/prism/logstream/mod.rs Removed all logic and struct fields related to fetching and returning distinct source values in dataset responses; deleted get_distinct_entries method.
src/rbac/role.rs Added Action::GetRetention to the default actions for the "Reader" role in reader_perm_builder.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant PrismHomeHandlers
    participant HomeLogic

    Client->>Server: GET /home
    Server->>PrismHomeHandlers: home_api(req)
    PrismHomeHandlers->>HomeLogic: generate_home_response(key)
    HomeLogic-->>PrismHomeHandlers: HomeResponse
    PrismHomeHandlers-->>Server: JSON(HomeResponse)
    Server-->>Client: Response

    Client->>Server: GET /home/search
    Server->>PrismHomeHandlers: home_search(req)
    PrismHomeHandlers->>HomeLogic: generate_home_search_response(key, query)
    HomeLogic-->>PrismHomeHandlers: HomeSearchResponse
    PrismHomeHandlers-->>Server: JSON(HomeSearchResponse)
    Server-->>Client: Response
Loading

Possibly related PRs

  • Feat: Prism APIs #1188: The main PR expands the /home endpoint into a scoped set of routes including a new /search route and adds a new handler home_search that calls generate_home_search_response, while the retrieved PR introduces the initial /home endpoint and related alert info structures; thus, the main PR builds directly upon and modifies the same Prism home API functionality introduced in the retrieved PR.

Suggested labels

for next release

Poem

In the warren, routes now bloom,
/home and /search make extra room.
The search is split, responses neat,
Reader roles get a small treat.
Distinct fields gone, the code is clean—
A rabbit’s hop in API routine! 🐇
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 041ef30 and cfa008d.

📒 Files selected for processing (1)
  • src/handlers/http/prism_home.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/handlers/http/prism_home.rs
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: coverage
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
✨ Finishing Touches
  • 📝 Generate Docstrings

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 with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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 our support 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 to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in 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 the configuration 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 our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot 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: 2

🧹 Nitpick comments (3)
src/prism/home/mod.rs (3)

47-52: StreamStats appears unused & carries commented-out fields

StreamStats is declared but nothing in this module (nor the response type) uses it except for the temporary summary variable created later.
Keeping dead code and commented-out field stubs (stream_count, log_source_count) adds noise and invites drift.

Consider deleting the struct (and the accompanying aggregation code) or, if you intend to expose a summary in the JSON payload soon, actually add it to HomeResponse.


148-156: summary is computed but never returned

The loop aggregates events, ingestion, and storage into summary.stats_summary.*, yet summary is never used after this block.
This is both a wasted O(n) pass and will raise an “unused variable” compiler warning.

Two quick fixes:

-    let mut summary = StreamStats::default();
+    // let mut summary = StreamStats::default();   // remove until we need it

and inside the loop:

-                summary.stats_summary.events += dated_stats.events;
-                summary.stats_summary.ingestion += dated_stats.ingestion_size;
-                summary.stats_summary.storage += dated_stats.storage_size;

Or, if a total summary is valuable, add a summary: StreamStats field to HomeResponse so callers can see the roll-up.


293-309: Minor: unnecessary clone() of SessionKey in authorization loop

Users.authorize only needs an &SessionKey, but each iteration clones the key, allocating each time:

Users.authorize(key.clone(), Action::ListStream, Some(logstream), None)

You can pass a reference instead:

Users.authorize(key, Action::ListStream, Some(logstream), None)

(assuming the signature supports it). This avoids repeated heap allocations in tight loops.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01d4449 and 8716140.

📒 Files selected for processing (5)
  • src/handlers/http/modal/server.rs (1 hunks)
  • src/handlers/http/prism_home.rs (2 hunks)
  • src/prism/home/mod.rs (4 hunks)
  • src/prism/logstream/mod.rs (1 hunks)
  • src/rbac/role.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: coverage
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
🔇 Additional comments (9)
src/rbac/role.rs (1)

327-327: Appropriate permission addition for Reader role.

Adding the GetRetention action to the reader role permissions aligns with the PR objective of updating reader privileges. This allows readers to access retention information for streams they have permission to read.

src/handlers/http/prism_home.rs (2)

22-22: Correctly updated import for new search functionality.

The import statement now includes the new generate_home_search_response function along with the existing imports.


41-48: Well-implemented new handler for the home search endpoint.

The home_search handler follows the same pattern as the existing home_api handler, with proper session key extraction and error handling. This implementation is consistent with the existing code style and error handling approach.

src/handlers/http/modal/server.rs (1)

151-155: Good refactoring of route handling for home API.

The method has been changed from returning a single Resource to returning a Scope that contains two routes:

  1. The root path ("") which maps to the existing home_api handler
  2. A new /search path which maps to the new home_search handler

This approach maintains backward compatibility while adding the new search endpoint, which aligns perfectly with the PR objectives.

src/prism/logstream/mod.rs (5)

35-36: Removed unnecessary imports related to distinct values functionality.

The import statement has been simplified by removing imports that were specifically used for the now-removed distinct values feature. This is part of the overall cleanup related to removing the distinct values feature from the datasets API.


39-40: Simplified imports after removing distinct values feature.

The import statement now focuses only on necessary components after the removal of the distinct values feature.


43-44: Removed TimeParseError import that was used for distinct values.

This change completes the import cleanup related to the removed distinct values feature.


199-214: Dataset response structure appropriately simplified.

The PrismDatasetResponse struct no longer includes the distinct_sources field that was previously used to store distinct values. This aligns with the PR objective to remove the distinct values feature from the datasets API. The structure now contains only the essential information needed for the response.


308-328: Streamlined dataset response construction.

The build_dataset_response method has been simplified to no longer fetch and include distinct values. This directly implements the PR objective of removing the distinct values feature, potentially improving performance by eliminating unnecessary data fetching operations.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 6, 2025
Copy link

@coderabbitai coderabbitai bot 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: 0

♻️ Duplicate comments (1)
src/prism/home/mod.rs (1)

346-363: Consider simplifying redundant error handling

Similar to the dashboard titles function, there's redundant error handling here. As previously confirmed, filter IDs are guaranteed to never be None.

You could simplify this to:

-            id: filter
-                .filter_id
-                .as_ref()
-                .ok_or_else(|| anyhow::Error::msg("Filter ID is null"))
-                .unwrap()
-                .clone(),
+            id: filter.filter_id.as_ref().unwrap().clone(),

Again, the current implementation provides a better error message, so this is purely a stylistic suggestion.

🧹 Nitpick comments (2)
src/prism/home/mod.rs (2)

327-344: Consider simplifying redundant error handling

While this pattern works correctly (as confirmed in previous discussions), the ok_or_else(...).unwrap() sequence is technically redundant since dashboard IDs are guaranteed to never be None.

You could simplify this to:

-            id: dashboard
-                .dashboard_id
-                .as_ref()
-                .ok_or_else(|| anyhow::Error::msg("Dashboard ID is null"))
-                .unwrap()
-                .clone(),
+            id: dashboard.dashboard_id.as_ref().unwrap().clone(),

The current implementation provides a better error message, so this is purely a stylistic suggestion.


100-101: Consider adding a descriptive error message

For consistency with other error handling patterns in this file, consider adding a descriptive error message to this unwrap.

-                .unwrap()
+                .unwrap_or_else(|| panic!("Date calculation failed, this should never happen"))

Or use a similar pattern to other parts of the code:

-                .unwrap()
+                .expect("Date calculation failed")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8716140 and 196a2a0.

📒 Files selected for processing (1)
  • src/prism/home/mod.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/prism/home/mod.rs (1)
Learnt from: nikhilsinhaparseable
PR: parseablehq/parseable#1307
File: src/prism/home/mod.rs:358-375
Timestamp: 2025-05-06T09:28:39.559Z
Learning: In Parseable, filter_id, dashboard_id, and correlation IDs are generated by the server at creation time and are guaranteed to never be None when listing/retrieving these resources.
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: coverage
🔇 Additional comments (3)
src/prism/home/mod.rs (3)

77-85: Well-structured separation of concerns!

You've effectively split the response types to separate aggregate data (HomeResponse) from search-related metadata (HomeSearchResponse). This aligns with the API changes described in the PR objectives, making each endpoint more focused and maintainable.


89-91: Clean concurrency model for simplified home response

The tokio::join! macro is now correctly updated to only fetch the data needed for the simplified HomeResponse, removing the fetching of title information which has been moved to the search endpoint.


257-278: Well-implemented search endpoint handler

The new generate_home_search_response function effectively uses concurrency through tokio::join! to fetch all title and ID data in parallel, following the same patterns as the main home response. The error handling is consistent and appropriate.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 6, 2025
Copy link

@coderabbitai coderabbitai bot 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: 0

🧹 Nitpick comments (2)
src/prism/home/mod.rs (2)

333-334: Consider defensive unwrapping for dashboard IDs

While I understand from prior discussions that dashboard IDs are generated by the server and can never be None, consider using a more descriptive unwrap pattern:

-id: dashboard.dashboard_id.as_ref().unwrap().clone(),
+id: dashboard
+    .dashboard_id
+    .clone()
+    .unwrap_or_else(|| panic!("Dashboard ID unexpectedly null despite server guarantee")),

This would provide more context in the extremely unlikely case of a panic.


347-348: Similar unwrap pattern for filter IDs

The same suggestion applies to filter IDs - consider a more descriptive unwrap for better debugging context if needed.

-id: filter.filter_id.as_ref().unwrap().clone(),
+id: filter
+    .filter_id
+    .clone()
+    .unwrap_or_else(|| panic!("Filter ID unexpectedly null despite server guarantee")),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 196a2a0 and 17c417e.

📒 Files selected for processing (1)
  • src/prism/home/mod.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/prism/home/mod.rs (1)
Learnt from: nikhilsinhaparseable
PR: parseablehq/parseable#1307
File: src/prism/home/mod.rs:358-375
Timestamp: 2025-05-06T09:28:39.559Z
Learning: In Parseable, filter_id, dashboard_id, and correlation IDs are generated by the server at creation time and are guaranteed to never be None when listing/retrieving these resources.
🧬 Code Graph Analysis (1)
src/prism/home/mod.rs (4)
src/alerts/mod.rs (4)
  • get_alerts_info (982-1019)
  • new (114-120)
  • new (155-167)
  • new (178-184)
src/parseable/mod.rs (1)
  • new (136-148)
src/storage/mod.rs (2)
  • new (182-184)
  • new (195-201)
src/metadata.rs (1)
  • new (95-130)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: coverage
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
🔇 Additional comments (5)
src/prism/home/mod.rs (5)

79-85: Well-structured new HomeSearchResponse type

The new structure clearly separates search metadata from the main home response, maintaining a clean one-concern-per-endpoint design.


87-91: Simplified concurrency pattern in generate_home_response

You've successfully refactored this function to focus on essential data, removing the title fetching operations that have been moved to the new search endpoint.


153-158: Streamlined response construction

The HomeResponse structure has been properly updated to match the simplified data fetching pattern. This eliminates unnecessary metadata from the main home endpoint.


256-277: Well-implemented search endpoint handler

The new generate_home_search_response function makes good use of concurrent execution with tokio::join! to efficiently fetch all the title data in parallel. Error handling is properly implemented with the ? operator.


354-366: Error type unchanged and still comprehensive

The PrismHomeError enum correctly handles all the possible error cases for both the original home endpoint and the new search endpoint.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 6, 2025
request - `http://localhost:8000/api/prism/v1/home/search?key=frontend`

response -
```
{
    "resources": [
        {
            "id": "e890c2f70362528b57d528b65a39de62bbd3c65f90f6923dce25e27a8a66e8a4",
            "name": "select flags not 0",
            "resource_type": "Filter"
        },
        {
            "id": "e71d1affa4ad72136e03092a717a4b0e0c3fd6d643a09572ad65e1748a5c2df8",
            "name": "body not null",
            "resource_type": "Filter"
        },
        {
            "id": "6fe16f99b05566d7d4a598a7f0fa2604379d75164cdda5657c7fdbf61e54a555",
            "name": "select *",
            "resource_type": "Filter"
        },
        {
            "id": "fcda9d6a2b98c3368cbf1d903bb408e59f084df2dcb7c7d5d7b044e800ec1437",
            "name": "frontend limit",
            "resource_type": "Filter"
        }
    ]
}
```
Copy link

@coderabbitai coderabbitai bot 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: 1

♻️ Duplicate comments (2)
src/prism/home/mod.rs (2)

378-378: IDs guaranteed to be non-null by the server.

Based on previous discussions in PR comments, dashboard_id is guaranteed to be present by the server implementation, so this unwrap is safe. However, for better code readability, you might consider adding a comment explaining this guarantee.


405-405: IDs guaranteed to be non-null by the server.

Similar to dashboard_id, filter_id is guaranteed to be present by the server implementation, making this unwrap safe. Consider adding a comment for clarity.

🧹 Nitpick comments (2)
src/prism/home/mod.rs (2)

107-107: Consider handling potential panic in date calculation.

Using expect here could cause a runtime panic if the date conversion fails. While this is unlikely to happen in practice, consider using a more robust error handling approach.

-                .expect("Date conversion failed")
+                .ok_or_else(|| PrismHomeError::Anyhow(anyhow::Error::msg("Date conversion failed")))?

286-294: Consider aligning stream filtering approach with other resources.

While other resources are filtered within their respective helper functions, stream filtering is done in the main function after fetching. Consider moving this filtering logic into the get_stream_titles function for consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17c417e and 041ef30.

📒 Files selected for processing (2)
  • src/handlers/http/prism_home.rs (2 hunks)
  • src/prism/home/mod.rs (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: coverage
🔇 Additional comments (6)
src/prism/home/mod.rs (4)

67-71: Simplified HomeResponse structure aligns with PR objectives.

The HomeResponse struct is now streamlined to only include essential data (alerts_info, stats_details, and datasets), removing all of the resource titles. This separation of concerns is good design - having basic information in the home response and detailed search functionality in a separate endpoint.


73-92: Well-structured resource representation.

The new types (ResourceType, Resource, and HomeSearchResponse) provide a clean and unified way to represent different resource types in the system. This abstraction allows for consistent handling of various resources in the search response.


263-296: Clean implementation of search functionality.

The new generate_home_search_response function effectively fetches and filters resources based on the query string. The concurrent fetching of different resource types is a good approach for performance.


434-435: Good error handling for the search functionality.

Adding a specific error variant for invalid query parameters with appropriate HTTP status code mapping is a good practice.

src/handlers/http/prism_home.rs (2)

21-24: Import updates for new search functionality.

The imports are appropriately updated to include the new generate_home_search_response function.


26-26: Good use of constants for query parameters.

Using a constant for the query parameter name enhances maintainability and reduces the risk of inconsistency.

@nitisht nitisht merged commit 81769b5 into parseablehq:main May 8, 2025
14 checks passed
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.

2 participants