Skip to content

basic mongodb indexig added#1264

Merged
GregJohnStewart merged 6 commits into
Epic-Breakfast-Productions:developmentfrom
axgiri:dev/301-mongodb-indexing
May 21, 2026
Merged

basic mongodb indexig added#1264
GregJohnStewart merged 6 commits into
Epic-Breakfast-Productions:developmentfrom
axgiri:dev/301-mongodb-indexing

Conversation

@axgiri
Copy link
Copy Markdown
Member

@axgiri axgiri commented May 16, 2026

Checklist:

  • Tested

issue #301 (and #1259)

Summary by CodeRabbit

  • New Features

    • Automated MongoDB index initialization during application startup improves database query performance by creating indexes on frequently accessed fields
    • Individual services now declare index requirements for automatic management and creation
  • Chores

    • Enhanced startup workflow ensures database indexes are initialized after schema upgrades

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

This PR adds MongoDB index initialization to the startup lifecycle. MongoDbAwareService gains contract methods for index creation, multiple services declare their indexes, a handler orchestrates initialization across all services and databases, and the startup bean wires everything together during application startup.

Changes

MongoDB Index Initialization

Layer / File(s) Summary
Base contract and default index initialization
software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/service/mongo/MongoDbAwareService.java
MongoDbAwareService adds getDbIndexes() returning an empty list by default, and initDb(String oqmDbIdOrName) that iterates declared indexes and calls createIndex on the service's collection.
Service index declarations
software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/service/mongo/InventoryItemService.java, ItemListService.java, StorageBlockService.java
Three services override getDbIndexes() to declare MongoDB ascending indexes on name (InventoryItem and ItemList) and location (StorageBlock) fields.
Initialization orchestrator
software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/scheduled/MongoInitializationHandler.java
New CDI Singleton injects OqmDatabaseService and all MongoDbAwareService instances, provides initDb() to iterate databases and call initDb(dbName) on each service.
Startup lifecycle integration
software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/scheduled/LifecycleBean.java
LifecycleBean injects MongoInitializationHandler and invokes initDb() during startup after schema upgrade, before final startup completion log.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

Hoist the sails, me hearty! The indexes be set in place,
From startup's morning watch to MongoDB's embrace,
Each service declares what treasures must be found,
A handler orchestrates 'cross databases all around,
Now the helm be steerin' true, with every field in bound! ⚓

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is largely minimal, with only a tested checklist item marked and issue references provided, lacking substantive detail about the MongoDB indexing changes. Expand the description to explain what MongoDB indexes were added, why they improve performance, and provide context for the architectural changes introduced by MongoInitializationHandler.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'basic mongodb indexig added' contains a typo ('indexig' instead of 'indexing') and accurately describes the main change—adding MongoDB indexing support across multiple services.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@axgiri
Copy link
Copy Markdown
Member Author

axgiri commented May 16, 2026

image

@axgiri axgiri changed the base branch from main to development May 16, 2026 19:38
Copy link
Copy Markdown
Contributor

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b8f79e69-de84-4eef-9111-d9225b2bf4c3

📥 Commits

Reviewing files that changed from the base of the PR and between 971f8ac and 0462e2d.

📒 Files selected for processing (6)
  • software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/scheduled/LifecycleBean.java
  • software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/scheduled/MongoInitializationHandler.java
  • software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/service/mongo/InventoryItemService.java
  • software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/service/mongo/ItemListService.java
  • software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/service/mongo/MongoDbAwareService.java
  • software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/service/mongo/StorageBlockService.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: CI-Pipeline / Build
🔇 Additional comments (4)
software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/service/mongo/InventoryItemService.java (1)

16-16: LGTM!

Also applies to: 429-434

software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/service/mongo/ItemListService.java (1)

7-7: LGTM!

Also applies to: 16-16, 69-74

software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/scheduled/MongoInitializationHandler.java (1)

11-27: LGTM!

software/core/oqm-core-api/src/main/java/tech/ebp/oqm/core/api/scheduled/LifecycleBean.java (1)

46-47: LGTM!

Also applies to: 151-152

Copy link
Copy Markdown
Contributor

@GregJohnStewart GregJohnStewart left a comment

Choose a reason for hiding this comment

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

Overall, nice start. Just some polish for the final form

@axgiri axgiri force-pushed the dev/301-mongodb-indexing branch from 0462e2d to d184c27 Compare May 17, 2026 09:50
@axgiri axgiri requested a review from GregJohnStewart May 17, 2026 19:46
Copy link
Copy Markdown
Contributor

@GregJohnStewart GregJohnStewart left a comment

Choose a reason for hiding this comment

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

One last bit... in the theme of learning about best practices

@axgiri axgiri requested a review from GregJohnStewart May 20, 2026 21:44
@GregJohnStewart GregJohnStewart merged commit f8816b1 into Epic-Breakfast-Productions:development May 21, 2026
3 of 7 checks passed
This was referenced May 21, 2026
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