• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / b81985d4-b4fc-4cea-9b26-3f7023663267

01 Dec 2025 08:39PM UTC coverage: 75.991% (+4.4%) from 71.597%
b81985d4-b4fc-4cea-9b26-3f7023663267

Pull #2250

circleci

JaymeeH
linting
Pull Request #2250: Organize the submission provenance for a project

3 of 36 new or added lines in 2 files covered. (8.33%)

1079 existing lines in 42 files now uncovered.

2491 of 3278 relevant lines covered (75.99%)

251.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/app/operations/project_search.rb
UNCOV
1
class ProjectSearch < Dry::Operation
1✔
UNCOV
2
    def call(search_string:, requestor:, field_name: "Title")
1✔
UNCOV
3
        verified_search_string = step verify_search_string(search_string)
10✔
UNCOV
4
        result_ids = step query_mediaflux(search_string: verified_search_string, requestor:, field_name:)
9✔
UNCOV
5
        step convert_results(result_ids)
8✔
UNCOV
6
    end
7

UNCOV
8
    private
1✔
9

UNCOV
10
    def verify_search_string(search_string)
1✔
11
        # An empty search does not make sense
UNCOV
12
        if search_string.blank?
10✔
13
            Failure("Search String cannot be empty")
1✔
14
        # Assuming there may be more verifications in the future
UNCOV
15
        else
UNCOV
16
            Success(search_string)
9✔
UNCOV
17
        end
UNCOV
18
    end
19

UNCOV
20
    def query_mediaflux(search_string:, requestor:, field_name:)
1✔
UNCOV
21
      query = mediaflux_query(search_string:, requestor:, field_name:)
9✔
UNCOV
22
      if query.error?
9✔
23
        Failure("Error querying mediaflux: #{query.response_error[:message]}")
1✔
UNCOV
24
      else
UNCOV
25
        result_ids = query.result_items.map{|result| result[:id]}
16✔
UNCOV
26
        Success(result_ids)
8✔
UNCOV
27
      end
UNCOV
28
    end
29

UNCOV
30
    def mediaflux_query(search_string:, requestor:, field_name:)
1✔
UNCOV
31
      aql_query = "xpath(tigerdata:project/#{field_name}) matches ignore-case '#{search_string}'"
9✔
UNCOV
32
      Mediaflux::QueryRequest.new(session_token: requestor.mediaflux_session, aql_query: , iterator: false )
9✔
UNCOV
33
    end
34

35

UNCOV
36
    def convert_results(result_ids)
1✔
UNCOV
37
      projects_not_found = []
8✔
UNCOV
38
      projects = []
8✔
UNCOV
39
      result_ids.map do |mediaflux_id|
8✔
UNCOV
40
        project = Project.find_by(mediaflux_id: )
8✔
UNCOV
41
        if project.blank?
8✔
UNCOV
42
          projects_not_found << mediaflux_id
1✔
UNCOV
43
        else
UNCOV
44
          projects << project
7✔
UNCOV
45
        end
UNCOV
46
      end
UNCOV
47
      if projects_not_found.count > 0
8✔
UNCOV
48
        Rails.logger.error("The following Mediaflux Projects were not found in the Rails database: #{projects_not_found.join(', ')}")
1✔
UNCOV
49
        Honeybadger.notify("The following Mediaflux Projects were not found in the Rails database: #{projects_not_found.join(', ')}")
1✔
UNCOV
50
      end
UNCOV
51
      Success(projects)
8✔
UNCOV
52
    end
UNCOV
53
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc