Reduce code duplication#82
Merged
Merged
Conversation
Closed
Reviewer's GuideThe pull request eliminates repetitive function clauses across the codebase by unifying all API calls to a single arity that accepts a keyword list of options (including the Sequence Diagram: Refactored API Call PatternsequenceDiagram
participant Client
participant ExTypesenseModule as ExTypesense.Module
participant OpenApiLib as OpenApiTypesense.SubModuleAPI
Client->>ExTypesenseModule: refactored_function(regular_args*, opts_with_conn_and_params)
ExTypesenseModule->>OpenApiLib: underlying_api_call(regular_args*, opts_with_conn_and_params)
OpenApiLib-->>ExTypesenseModule: ApiResponse
ExTypesenseModule-->>Client: Result
Updated Class Diagram for ExTypesense.CollectionclassDiagram
class ExTypesense.Collection {
+list_collections(opts: keyword) : Result
+create_collection_with_alias(schema: map_or_module, opts: keyword) : Result
+create_collection(schema: map_or_module, opts: keyword) : Result
+clone_collection(src_coll: string_or_module, new_coll_name: string, opts: keyword) : Result
+get_collection(coll_name_or_module: string_or_module, opts: keyword) : Result
+update_collection_fields(name_or_module: string_or_module, fields: map, opts: keyword) : Result
+drop_collection(name_or_module: string_or_module, opts: keyword) : Result
+list_collection_aliases(opts: keyword) : Result
+get_collection_alias(alias_name_or_module: string_or_module, opts: keyword) : Result
+upsert_collection_alias(alias_name: string, coll_name_or_module: string_or_module, opts: keyword) : Result
+delete_collection_alias(alias_name: string, opts: keyword) : Result
}
Updated Class Diagram for ExTypesense.DocumentclassDiagram
class ExTypesense.Document {
+get_document(coll_name_or_module: string_or_module, doc_id: string, opts: keyword) : Result
+import_documents(coll_name_or_module: string_or_module, documents: list, opts: keyword) : Result
+index_document(doc_map_or_struct: map_or_struct, opts: keyword) : Result
+index_document(coll_name: string, doc_body: map, opts: keyword) : Result
+update_document(doc_map_or_struct: map_or_struct, opts: keyword) : Result
+update_documents_by_query(coll_name_or_module: string_or_module, body: map, opts: keyword) : Result
+delete_document(doc_map_or_struct: map_or_struct, opts: keyword) : Result
+delete_document(coll_name: string, doc_id: string, opts: keyword) : Result
+export_documents(coll_name_or_module: string_or_module, opts: keyword) : Result
+delete_documents_by_query(coll_name_or_module: string_or_module, opts: keyword) : Result
+delete_all_documents(coll_name_or_module: string_or_module, opts: keyword) : Result
}
Updated Class Diagram for ExTypesense.ClusterclassDiagram
class ExTypesense.Cluster {
+health(opts: keyword) : Result
+api_stats(opts: keyword) : Result
+cluster_metrics(opts: keyword) : Result
+create_snapshot(opts: keyword) : Result
+compact_db(opts: keyword) : Result
+clear_cache(opts: keyword) : Result
+get_schema_changes(opts: keyword) : Result
+toggle_slow_request_log(config: map, opts: keyword) : Result
+vote(opts: keyword) : Result
}
Updated Class Diagram for ExTypesense.AnalyticsclassDiagram
class ExTypesense.Analytics {
+create_analytics_rule(body: map, opts: keyword) : Result
+create_analytics_event(body: map, opts: keyword) : Result
+list_analytics_rules(opts: keyword) : Result
+get_analytics_rule(rule_name: string, opts: keyword) : Result
+upsert_analytics_rule(rule_name: string, body: map, opts: keyword) : Result
+delete_analytics_rule(rule_name: string, opts: keyword) : Result
}
Updated Class Diagram for ExTypesense.CurationclassDiagram
class ExTypesense.Curation {
+get_override(collection_name_or_module: string_or_module, override_id: string, opts: keyword) : Result
+upsert_override(collection_name_or_module: string_or_module, override_id: string, body: map, opts: keyword) : Result
+list_overrides(collection_name_or_module: string_or_module, opts: keyword) : Result
+delete_override(collection_name_or_module: string_or_module, override_id: string, opts: keyword) : Result
}
Updated Class Diagram for ExTypesense.ConversationclassDiagram
class ExTypesense.Conversation {
+create_model(body: map, opts: keyword) : Result
+get_model(model_id: string, opts: keyword) : Result
+update_model(model_id: string, body: map, opts: keyword) : Result
+list_models(opts: keyword) : Result
+delete_model(model_id: string, opts: keyword) : Result
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @jaeyson - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 9 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #81
The purpose of this change is to reduce code duplication and to streamline passing of options (including
conn). The breaking change here isconnis now part ofopts. When calling functions, see example below:Summary by Sourcery
Streamline the API by consolidating all client entrypoints to a single keyword-list signature with a
connoption and other parameters as options; remove redundant overloaded clauses and aliases; update documentation, examples, and tests to reflect the unified interface; bumpopen_api_typesensedependency to 1.0 and add upgrade instructions in the README.Enhancements:
optskeyword-list parameter (includingconn), removing duplicated arity overloadsConnectionaliases and redundant delegatesconn: connform instead of separateconnargumentsBuild:
open_api_typesensedependency to “~> 1.0”Documentation: