lib/checkoff/task_searches.rb in checkoff-0.139.0 vs lib/checkoff/task_searches.rb in checkoff-0.145.0

- old
+ new

@@ -11,10 +11,11 @@ require_relative 'task_selectors' require 'asana/resource_includes/collection' require 'asana/resource_includes/response_helper' require 'checkoff/internal/search_url' +require 'checkoff/internal/logging' # https://developers.asana.com/reference/searchtasksforworkspace module Checkoff # Run task searches against the Asana API class TaskSearches @@ -23,10 +24,11 @@ DAY = 24 * HOUR REALLY_LONG_CACHE_TIME = HOUR * 1 LONG_CACHE_TIME = MINUTE * 15 SHORT_CACHE_TIME = MINUTE + include Logging include Asana::Resources::ResponseHelper # @!parse # extend CacheMethod::ClassMethods @@ -68,10 +70,11 @@ # @return [Enumerable<Asana::Resources::Task>] def task_search(workspace_name, url, extra_fields: []) workspace = workspaces.workspace_or_raise(workspace_name) # @sg-ignore api_params, task_selector = @search_url_parser.convert_params(url) + debug { "Task search params: api_params=#{api_params}, task_selector=#{task_selector}" } raw_task_search(api_params, workspace_gid: workspace.gid, task_selector: task_selector, extra_fields: extra_fields) end cache_method :task_search, LONG_CACHE_TIME @@ -93,10 +96,24 @@ tasks = @asana_resources_collection_class.new(parse(client.get(path, params: api_params, options: options)), type: Asana::Resources::Task, client: client) + + if tasks.length == 100 + raise 'Too many results returned. ' \ + 'Please narrow your search in ways expressible through task search API: ' \ + 'https://developers.asana.com/reference/searchtasksforworkspace' + end + + debug { "#{tasks.length} raw tasks returned" } + tasks.select { |task| task_selectors.filter_via_task_selector(task, task_selector) } + end + + # @return [Hash] + def as_cache_key + {} end private # @param [Array<String>] extra_fields