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

pulibrary / tigerdata-app / 21b3684e-2cf2-4e1c-adb5-a44be328e358

07 Nov 2025 03:59PM UTC coverage: 82.627% (-8.4%) from 91.075%
21b3684e-2cf2-4e1c-adb5-a44be328e358

Pull #2163

circleci

carolyncole
Handle error fetching project list
Pull Request #2163: Logs Mediaflux errors when fetching the project list

5 of 8 new or added lines in 1 file covered. (62.5%)

891 existing lines in 32 files now uncovered.

2592 of 3137 relevant lines covered (82.63%)

353.31 hits per line

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

97.67
/app/models/mediaflux/query_request.rb
1
# frozen_string_literal: true
UNCOV
2
module Mediaflux
2✔
UNCOV
3
  class QueryRequest < Request
2✔
UNCOV
4
    attr_reader :aql_query, :collection, :action, :deep_search, :iterator
2✔
5

6
    # Constructor
7
    # @param session_token [String] the API token for the authenticated session
8
    # @param aql_query [String] Optional AQL query string
9
    # @param collection [Integer] Optional collection id
10
    # @param action [String] Optional, by default it uses get-name but it could also be get-meta to get all
11
    #                        the fields for the assets or `get-values` to get a limited list of fields.
12
    # @param deep_search [Bool] Optional, false by default. When true queries the collection and it subcollections.
13
    # @param iterator [Bool] Optional, true by default. When true returns an iterator.  When false returns a list of results
UNCOV
14
    def initialize(session_token:, aql_query: nil, collection: nil, action: "get-values", deep_search: false, iterator: true)
2✔
UNCOV
15
      super(session_token: session_token)
41✔
UNCOV
16
      @aql_query = aql_query
41✔
UNCOV
17
      @collection = collection
41✔
UNCOV
18
      @action = action
41✔
UNCOV
19
      @deep_search = deep_search
41✔
UNCOV
20
      @iterator = iterator
41✔
UNCOV
21
    end
22

23
    # Specifies the Mediaflux service to use when running a query
24
    # @return [String]
UNCOV
25
    def self.service
2✔
UNCOV
26
      "asset.query"
82✔
UNCOV
27
    end
28

29
    # Returns the iterator that could be used to fetch the data
UNCOV
30
    def result
2✔
UNCOV
31
      xml = response_xml
30✔
UNCOV
32
      xml.xpath("/response/reply/result/iterator").text.to_i
30✔
UNCOV
33
    end
34

UNCOV
35
    def result_items
2✔
UNCOV
36
      xml = response_xml
10✔
UNCOV
37
      xml.xpath("/response/reply/result").children.map do |node|
10✔
UNCOV
38
        {
UNCOV
39
          id: node.xpath("./@id").text,
11✔
UNCOV
40
          name: node.xpath("./name").text,
UNCOV
41
          path: node.xpath("./path").text
UNCOV
42
        }
UNCOV
43
      end
UNCOV
44
    end
45

UNCOV
46
    private
2✔
47

UNCOV
48
      def build_http_request_body(name:)
2✔
UNCOV
49
        super do |xml|
82✔
UNCOV
50
          xml.args do
82✔
51
            # TODO: there is a bug in mediaflux that does not allow the comented out line to paginate
52
            #      For the moment we will utilize the where clasue that does allow pagination
53
            # xml.collection collection if collection.present?
UNCOV
54
            if collection.present?
82✔
UNCOV
55
              xml.where mf_where(collection)
60✔
UNCOV
56
            end
UNCOV
57
            xml.where aql_query if aql_query.present?
82✔
UNCOV
58
            xml.action action if action.present?
82✔
UNCOV
59
            declare_get_values_fields(xml) if action == "get-values"
82✔
UNCOV
60
            xml.as "iterator" if iterator
82✔
UNCOV
61
          end
UNCOV
62
        end
UNCOV
63
      end
64

UNCOV
65
      def mf_where(collection)
2✔
UNCOV
66
        if deep_search
60✔
UNCOV
67
          "asset in static collection or subcollection of #{collection}"
60✔
UNCOV
68
        else
69
          "asset in collection #{collection}"
×
UNCOV
70
        end
UNCOV
71
      end
72

73
      # Adds the declarations to fetch specific fields
UNCOV
74
      def declare_get_values_fields(xml)
2✔
UNCOV
75
        declare_get_value_field(xml, "name", "name")
82✔
UNCOV
76
        declare_get_value_field(xml, "path", "path")
82✔
UNCOV
77
        declare_get_value_field(xml, "content/@total-size", "total-size")
82✔
UNCOV
78
        declare_get_value_field(xml, "mtime", "mtime")
82✔
UNCOV
79
        declare_get_value_field(xml, "@collection", "collection")
82✔
UNCOV
80
      end
81

82
      # Adds a single field declaration
UNCOV
83
      def declare_get_value_field(xml, field_xpath, field_name)
2✔
UNCOV
84
        xml.xpath do
410✔
UNCOV
85
          xml.parent.set_attribute("ename", field_name)
410✔
UNCOV
86
          xml.text(field_xpath)
410✔
UNCOV
87
        end
UNCOV
88
      end
UNCOV
89
  end
UNCOV
90
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