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

enable to pass config #91

Merged
merged 8 commits into from
Jan 20, 2024
Merged

enable to pass config #91

merged 8 commits into from
Jan 20, 2024

Conversation

kazumatsudo
Copy link
Owner

@kazumatsudo kazumatsudo commented Jan 20, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration system to enhance application flexibility and customization.
  • Improvements

    • Streamlined configuration access across various components of the application.
    • Simplified the initialization of queries and data structures with direct configuration injection.
  • Bug Fixes

    • Adjusted file writing logic for consistency and reliability.
  • Tests

    • Implemented comprehensive tests for the new configuration setup.
    • Updated existing tests to align with configuration changes.
  • Documentation

    • Updated documentation to reflect the new configuration approach and its usage in the application.

@kazumatsudo kazumatsudo self-assigned this Jan 20, 2024
Copy link

coderabbitai bot commented Jan 20, 2024

Walkthrough

The Scala project underwent a significant refactor, primarily focusing on the integration of a new Config class. This change centralized configuration management, allowing the removal of the ConfigFactory calls and direct property access within various classes. The update touched core application logic, domain layer, infrastructure queries, and test suites, ensuring that configuration settings are now passed explicitly through constructors and methods, enhancing modularity and testability.

Changes

Files Change Summary
src/main/scala/.../Main.scala, src/main/scala/.../GraphEdge.scala, src/main/scala/.../GraphVertex.scala, src/main/scala/.../EdgeQuery.scala, src/main/scala/.../VertexQuery.scala, src/main/scala/.../ByExhaustiveSearch.scala, src/main/scala/.../UsingSpecificKeyList.scala, src/main/scala/.../UsecaseBase.scala Integrated Config object, replaced ConfigFactory usage with direct Config access, and updated constructors and methods to accept Config as a parameter.
src/main/scala/utils/Config.scala, src/test/scala/utils/ConfigSpec.scala Added new Config class and corresponding test suite for managing configurations.
src/test/scala/.../GenerateTestData.scala, src/test/scala/.../MainSpec.scala, src/test/scala/.../GraphEdgeSpec.scala, src/test/scala/.../GraphVertexSpec.scala, src/test/scala/.../TableListSpec.scala, src/test/scala/.../RecordListSpec.scala, src/test/scala/.../EdgeQuerySpec.scala, src/test/scala/.../VertexQuerySpec.scala, src/test/scala/.../ByExhaustiveSearchSpec.scala, src/test/scala/.../UsingSpecificKeyListSpec.scala Modified test classes to instantiate and use the new Config object. Removed unnecessary imports.

🐇 "In the land of code where the wild rabbits roam,
A refactor swept through, a new Config to own.
No more scattered settings, just one source so neat,
With every constructor, our configs now meet." 🌟

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@codecov-commenter
Copy link

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (0126d05) 69.25% compared to head (8e86e93) 71.50%.

Files Patch % Lines
src/main/scala/Main.scala 0.00% 14 Missing ⚠️
src/main/scala/utils/FileUtility.scala 0.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   69.25%   71.50%   +2.25%     
==========================================
  Files          19       20       +1     
  Lines         348      372      +24     
  Branches       40       47       +7     
==========================================
+ Hits          241      266      +25     
+ Misses        107      106       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kazumatsudo kazumatsudo merged commit 677208f into main Jan 20, 2024
1 check passed
@kazumatsudo kazumatsudo deleted the feature/config branch January 20, 2024 11:52
@kazumatsudo kazumatsudo mentioned this pull request Jan 20, 2024
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0126d05 and 8e86e93.
Files selected for processing (21)
  • src/main/scala/Main.scala (7 hunks)
  • src/main/scala/domain/graph/GraphEdge.scala (3 hunks)
  • src/main/scala/domain/graph/GraphVertex.scala (3 hunks)
  • src/main/scala/infrastructure/EdgeQuery.scala (4 hunks)
  • src/main/scala/infrastructure/VertexQuery.scala (3 hunks)
  • src/main/scala/usecase/ByExhaustiveSearch.scala (4 hunks)
  • src/main/scala/usecase/UsecaseBase.scala (1 hunks)
  • src/main/scala/usecase/UsingSpecificKeyList.scala (4 hunks)
  • src/main/scala/utils/Config.scala (1 hunks)
  • src/main/scala/utils/FileUtility.scala (3 hunks)
  • src/test/scala/GenerateTestData.scala (5 hunks)
  • src/test/scala/MainSpec.scala (1 hunks)
  • src/test/scala/domain/graph/GraphEdgeSpec.scala (4 hunks)
  • src/test/scala/domain/graph/GraphVertexSpec.scala (4 hunks)
  • src/test/scala/domain/table/ddl/TableListSpec.scala (2 hunks)
  • src/test/scala/domain/table/dml/RecordListSpec.scala (2 hunks)
  • src/test/scala/infrastructure/EdgeQuerySpec.scala (3 hunks)
  • src/test/scala/infrastructure/VertexQuerySpec.scala (5 hunks)
  • src/test/scala/usecase/ByExhaustiveSearchSpec.scala (2 hunks)
  • src/test/scala/usecase/UsingSpecificKeyListSpec.scala (3 hunks)
  • src/test/scala/utils/ConfigSpec.scala (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/main/scala/utils/Config.scala
Additional comments: 49
src/main/scala/usecase/UsecaseBase.scala (1)
  • 14-14: Protected member config of type Config has been added to the UsecaseBase trait.
src/test/scala/utils/ConfigSpec.scala (1)
  • 9-18: The test case for the default configuration seems to correctly instantiate a Config object with expected values.
src/main/scala/utils/FileUtility.scala (2)
  • 15-20: The writeJson method now correctly accepts a directoryPath parameter and creates the directory if it does not exist.
  • 34-39: The writeSql method has been updated similarly to writeJson to accept a directoryPath parameter and create the directory if needed.
src/main/scala/domain/graph/GraphVertex.scala (3)
  • 9-15: GraphVertex class now correctly accepts a Config object and uses its properties to construct tableName and columnNamePrefixProperty.
  • 26-29: The toDdl method has been updated to use the Config object's properties for column names.
  • 40-40: The toDml method has been updated to use the Config object's properties for column names.
src/test/scala/MainSpec.scala (1)
  • 10-15: A config object has been added and is now passed to the ByExhaustiveSearch instantiation.
src/main/scala/infrastructure/EdgeQuery.scala (4)
  • 11-14: EdgeQuery class now correctly accepts a config parameter and uses it when creating GraphEdge instances.
  • 31-31: The getInEdgeList method has been updated to pass the config object to the GraphEdge constructor.
  • 48-51: The getList method has been updated to pass the config object to the GraphEdge constructor.
  • 70-70: The getOutEdgeList method has been updated to pass the config object to the GraphEdge constructor.
src/main/scala/infrastructure/VertexQuery.scala (3)
  • 11-14: VertexQuery class now correctly accepts a config parameter and uses it when creating GraphVertex instances.
  • 37-40: The getList method has been updated to pass the config object to the GraphVertex constructor.
  • 73-73: The getListByPropertyKey method has been updated to pass the config object to the GraphVertex constructor.
src/test/scala/domain/graph/GraphVertexSpec.scala (2)
  • 19-24: A config variable has been added and is used in the VertexQuery constructor.
  • 64-64: The config variable is correctly used in the GraphVertex constructor.
src/test/scala/domain/table/ddl/TableListSpec.scala (1)
  • 11-17: A config variable has been added and is used in the VertexQuery constructor.
src/test/scala/infrastructure/EdgeQuerySpec.scala (4)
  • 11-16: A config variable has been added and is used in the EdgeQuery constructor.
  • 24-27: The config variable is correctly used in the GraphEdge constructor and the getInEdgeList method.
  • 35-49: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [38-55]

The config variable is correctly used in the EdgeQuery constructor and the getList method.

  • 65-69: The config variable is correctly used in the getOutEdgeList method.
src/main/scala/domain/graph/GraphEdge.scala (3)
  • 11-20: GraphEdge class now correctly accepts a Config object and uses its properties to construct tableName and column names.
  • 31-42: The toDdl method has been updated to use the Config object's properties for column names.
  • 73-76: The toDml method has been updated to use the Config object's properties for column names.
src/test/scala/infrastructure/VertexQuerySpec.scala (3)
  • 11-16: A config variable has been added and is used in the VertexQuery constructor.
  • 22-36: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [25-42]

The config variable is correctly used in the getList method.

  • 50-64: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [53-70]

The config variable is correctly used in the getListByPropertyKey method.

src/test/scala/domain/graph/GraphEdgeSpec.scala (2)
  • 20-25: A config variable has been added and is used in the EdgeQuery constructor.
  • 43-49: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [46-69]

The config variable is correctly used in the GraphEdge constructor and the toDml method.

src/main/scala/usecase/ByExhaustiveSearch.scala (2)
  • 22-23: ByExhaustiveSearch class now correctly accepts a config parameter and uses it in its execution logic.
  • 34-40: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [37-66]

The execute method has been updated to use the config parameter when instantiating VertexQuery and EdgeQuery.

src/test/scala/usecase/UsingSpecificKeyListSpec.scala (1)
  • 13-23: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [19-33]

A config variable has been added and is used in the UsingSpecificKeyList instantiation.

src/main/scala/usecase/UsingSpecificKeyList.scala (2)
  • 35-35: UsingSpecificKeyList class now correctly accepts a config parameter and uses it in its execution logic.
  • 47-53: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [50-64]

The execute method has been updated to use the config parameter when instantiating VertexQuery and EdgeQuery.

src/main/scala/Main.scala (5)
  • 12-12: A config object of type Config has been instantiated using Config.default.
  • 25-30: The execute method has been refactored to use the config object for determining the use case command.
  • 39-49: The ByExhaustiveSearch and UsingSpecificKeyList classes are correctly instantiated with the config object.
  • 88-104: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [67-101]

The writeSql method calls have been updated to use the config object's properties for directory and file names.

  • 117-117: The traversal().withRemote method call has been updated to use the config object's properties.
src/test/scala/domain/table/dml/RecordListSpec.scala (1)
  • 5-15: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [11-85]

A config variable has been added and is used in the VertexQuery constructor and the toSqlSentence method.

src/test/scala/usecase/ByExhaustiveSearchSpec.scala (3)
  • 16-16: The import of utils.Config is correct and aligns with the PR objectives to use the new Config class.
  • 19-19: The addition of the config variable using Config.default is consistent with the PR objectives to pass configuration through the system.
  • 24-24: The ByExhaustiveSearch class is correctly instantiated with the config object, ensuring that configuration settings are passed as intended.
src/test/scala/GenerateTestData.scala (5)
  • 11-11: The import of utils.Config is correct and necessary for the use of the Config class within this file.
  • 19-19: The declaration of config using Config.default is appropriate and aligns with the PR objectives to use a centralized configuration object.
  • 166-166: The variable grapdbConnection is correctly assigned from config.graphDb.remoteGraphProperties, which is in line with the PR's goal to use structured configuration access.
  • 327-328: The file writing operation correctly uses config.usingSpecificKeyList.outputDirectory and config.usingSpecificKeyList.filename, which is consistent with the PR objectives to use the Config object for accessing configuration properties.
  • 335-337: The error handling in the recover block is appropriate, logging the error and exiting the system. This is a standard Scala practice for handling non-fatal exceptions in a standalone script.

@@ -163,10 +163,9 @@ object GenerateTestData extends StrictLogging {
/** @param args
*/
def main(args: Array[String]): Unit = {
val config = ConfigFactory.load()
val grapdbConnection = config.graphDb.remoteGraphProperties
Copy link

Choose a reason for hiding this comment

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

The logging statement correctly references the grapdbConnection variable. However, there is a typo in the variable name grapdbConnection; it should be graphdbConnection.

- val grapdbConnection = config.graphDb.remoteGraphProperties
+ val graphdbConnection = config.graphDb.remoteGraphProperties

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.

Suggested change
val grapdbConnection = config.graphDb.remoteGraphProperties
val graphdbConnection = config.graphDb.remoteGraphProperties

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.

None yet

2 participants