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

pulibrary / tigerdata-app / 8d70f2ab-acc5-4aab-b64b-743d66ddd2eb

29 Aug 2025 06:22PM UTC coverage: 87.983% (-0.1%) from 88.118%
8d70f2ab-acc5-4aab-b64b-743d66ddd2eb

Pull #1801

circleci

JaymeeH
Merge branch '1586-request-mailer' of https://github.com/pulibrary/tiger-data-app into 1586-request-mailer
Pull Request #1801: 1586 request mailer

10 of 10 new or added lines in 2 files covered. (100.0%)

1173 existing lines in 56 files now uncovered.

2482 of 2821 relevant lines covered (87.98%)

317.98 hits per line

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

97.37
/app/models/mediaflux/query_request.rb
1
# frozen_string_literal: true
UNCOV
2
module Mediaflux
1✔
UNCOV
3
  class QueryRequest < Request
1✔
UNCOV
4
    attr_reader :aql_query, :collection, :action, :deep_search
1✔
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.
UNCOV
13
    def initialize(session_token:, aql_query: nil, collection: nil, action: "get-values", deep_search: false)
1✔
UNCOV
14
      super(session_token: session_token)
43✔
UNCOV
15
      @aql_query = aql_query
43✔
UNCOV
16
      @collection = collection
43✔
UNCOV
17
      @action = action
43✔
UNCOV
18
      @deep_search = deep_search
43✔
UNCOV
19
    end
20

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

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

UNCOV
33
    private
1✔
34

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

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

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

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