Skip to content

Commit c67f226

Browse files
committed
Use Task model on all /settings/* tasks
Should have been implemented this way all along, but I digress.
1 parent 085793f commit c67f226

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

lib/meilisearch/index.rb

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,15 @@ def proximity_precision
609609
end
610610

611611
def update_proximity_precision(proximity_precision_attribute)
612-
http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
612+
response = http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
613+
614+
Models::Task.new(response, task_endpoint)
613615
end
614616

615617
def reset_proximity_precision
616-
http_delete("/indexes/#{@uid}/settings/proximity-precision")
618+
response = http_delete("/indexes/#{@uid}/settings/proximity-precision")
619+
620+
Models::Task.new(response, task_endpoint)
617621
end
618622

619623
### SETTINGS - SEARCH CUTOFF MS
@@ -623,11 +627,15 @@ def search_cutoff_ms
623627
end
624628

625629
def update_search_cutoff_ms(search_cutoff_ms_attribute)
626-
http_put("/indexes/#{@uid}/settings/search-cutoff-ms", search_cutoff_ms_attribute)
630+
response = http_put("/indexes/#{@uid}/settings/search-cutoff-ms", search_cutoff_ms_attribute)
631+
632+
Models::Task.new(response, task_endpoint)
627633
end
628634

629635
def reset_search_cutoff_ms
630-
http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
636+
response = http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
637+
638+
Models::Task.new(response, task_endpoint)
631639
end
632640

633641
### SETTINGS - LOCALIZED ATTRIBUTES
@@ -639,11 +647,15 @@ def localized_attributes
639647
def update_localized_attributes(new_localized_attributes)
640648
new_localized_attributes = Utils.transform_attributes(new_localized_attributes)
641649

642-
http_put("/indexes/#{@uid}/settings/localized-attributes", new_localized_attributes)
650+
response = http_put("/indexes/#{@uid}/settings/localized-attributes", new_localized_attributes)
651+
652+
Models::Task.new(response, task_endpoint)
643653
end
644654

645655
def reset_localized_attributes
646-
http_delete("/indexes/#{@uid}/settings/localized-attributes")
656+
response = http_delete("/indexes/#{@uid}/settings/localized-attributes")
657+
658+
Models::Task.new(response, task_endpoint)
647659
end
648660

649661
### SETTINGS - FACET SEARCH
@@ -653,11 +665,15 @@ def facet_search_setting
653665
end
654666

655667
def update_facet_search_setting(new_facet_search_setting)
656-
http_put("/indexes/#{@uid}/settings/facet-search", new_facet_search_setting)
668+
response = http_put("/indexes/#{@uid}/settings/facet-search", new_facet_search_setting)
669+
670+
Models::Task.new(response, task_endpoint)
657671
end
658672

659673
def reset_facet_search_setting
660-
http_delete("/indexes/#{@uid}/settings/facet-search")
674+
response = http_delete("/indexes/#{@uid}/settings/facet-search")
675+
676+
Models::Task.new(response, task_endpoint)
661677
end
662678

663679
### SETTINGS - PREFIX SEARCH
@@ -667,11 +683,15 @@ def prefix_search
667683
end
668684

669685
def update_prefix_search(new_prefix_search_setting)
670-
http_put("/indexes/#{@uid}/settings/prefix-search", new_prefix_search_setting)
686+
response = http_put("/indexes/#{@uid}/settings/prefix-search", new_prefix_search_setting)
687+
688+
Models::Task.new(response, task_endpoint)
671689
end
672690

673691
def reset_prefix_search
674-
http_delete("/indexes/#{@uid}/settings/prefix-search")
692+
response = http_delete("/indexes/#{@uid}/settings/prefix-search")
693+
694+
Models::Task.new(response, task_endpoint)
675695
end
676696

677697
### SETTINGS - EMBEDDERS
@@ -683,11 +703,15 @@ def embedders
683703
def update_embedders(new_embedders)
684704
new_embedders = Utils.transform_attributes(new_embedders)
685705

686-
http_patch("/indexes/#{@uid}/settings/embedders", new_embedders)
706+
response = http_patch("/indexes/#{@uid}/settings/embedders", new_embedders)
707+
708+
Models::Task.new(response, task_endpoint)
687709
end
688710

689711
def reset_embedders
690-
http_delete("/indexes/#{@uid}/settings/embedders")
712+
response = http_delete("/indexes/#{@uid}/settings/embedders")
713+
714+
Models::Task.new(response, task_endpoint)
691715
end
692716
end
693717
end

0 commit comments

Comments
 (0)