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

pulibrary / tigerdata-app / 5205f704-d89d-4c43-8cfa-9e6783edc33a

29 Feb 2024 07:04PM UTC coverage: 60.206% (-29.9%) from 90.092%
5205f704-d89d-4c43-8cfa-9e6783edc33a

push

circleci

jrgriffiniii
Ensuring that the storage usage and storage capacity is retrieved for
Mediaflux Projects and rendered on the "contents" Project View

11 of 34 new or added lines in 4 files covered. (32.35%)

451 existing lines in 34 files now uncovered.

935 of 1553 relevant lines covered (60.21%)

9.47 hits per line

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

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

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

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

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

34
      private
1✔
35

36
        def build_http_request_body(name:)
1✔
UNCOV
37
          super do |xml|
×
UNCOV
38
            xml.args do
×
39
              # TODO: there is a bug in mediaflux that does not allow the comented out line to paginate
40
              #      For the moment we will utilize the where clasue that does allow pagination
41
              # xml.collection collection if collection.present?
UNCOV
42
              if collection.present?
×
UNCOV
43
                xml.where mf_where(collection)
×
44
              end
UNCOV
45
              xml.where aql_query if aql_query.present?
×
UNCOV
46
              xml.action action if action.present?
×
UNCOV
47
              declare_get_values_fields(xml) if action == "get-values"
×
UNCOV
48
              xml.as "iterator"
×
49
            end
50
          end
51
        end
52

53
        def mf_where(collection)
1✔
UNCOV
54
          if deep_search
×
UNCOV
55
            "asset in static collection or subcollection of #{collection}"
×
56
          else
UNCOV
57
            "asset in collection #{collection}"
×
58
          end
59
        end
60

61
        # Adds the declarations to fetch specific fields
62
        def declare_get_values_fields(xml)
1✔
UNCOV
63
          declare_get_value_field(xml, "name", "name")
×
UNCOV
64
          declare_get_value_field(xml, "path", "path")
×
UNCOV
65
          declare_get_value_field(xml, "content/@total-size", "total-size")
×
UNCOV
66
          declare_get_value_field(xml, "mtime", "mtime")
×
UNCOV
67
          declare_get_value_field(xml, "@collection", "collection")
×
68
        end
69

70
        # Adds a single field declaration
71
        def declare_get_value_field(xml, field_xpath, field_name)
1✔
UNCOV
72
          xml.xpath do
×
UNCOV
73
            xml.parent.set_attribute("ename", field_name)
×
UNCOV
74
            xml.text(field_xpath)
×
75
          end
76
        end
77
    end
78
  end
79
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