• 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

92.86
/app/models/mediaflux/iterator_request.rb
1
# frozen_string_literal: true
UNCOV
2
module Mediaflux
1✔
UNCOV
3
  class IteratorRequest < Request
1✔
4
    # Constructor
5
    # @param session_token [String] the API token for the authenticated session
6
    # @iterator [Int] The iterator returned by Mediaflux (via QueryRequest)
UNCOV
7
    def initialize(session_token:, iterator:, action: "get-values", size: nil)
1✔
UNCOV
8
      super(session_token: session_token)
39✔
UNCOV
9
      @iterator = iterator
39✔
UNCOV
10
      @size = size
39✔
UNCOV
11
      @action = action
39✔
UNCOV
12
    end
13

14
    # Specifies the Mediaflux service to use when running a query
15
    # @return [String]
UNCOV
16
    def self.service
1✔
UNCOV
17
      "asset.query.iterate"
78✔
UNCOV
18
    end
19

20
    # Returns hash with the files fetched in this iteration as well as a flag on whether we are
21
    # done iterating (complete=true) or if we need to keep iterating
UNCOV
22
    def result
1✔
UNCOV
23
      xml = response_xml
39✔
UNCOV
24
      {
UNCOV
25
        files: parse_files(xml),
39✔
UNCOV
26
        complete: xml.xpath("/response/reply/result/iterated/@complete").text == "true",
UNCOV
27
        count: xml.xpath("/response/reply/result/iterated").text.to_i
UNCOV
28
      }
UNCOV
29
    end
30

UNCOV
31
    private
1✔
32

UNCOV
33
      def build_http_request_body(name:)
1✔
UNCOV
34
        super do |xml|
78✔
UNCOV
35
          xml.args do
78✔
UNCOV
36
            xml.id @iterator
78✔
UNCOV
37
            xml.size @size if @size.present?
78✔
UNCOV
38
          end
UNCOV
39
        end
UNCOV
40
      end
41

UNCOV
42
      def parse_files(xml)
1✔
UNCOV
43
        case @action
39✔
UNCOV
44
        when "get-name"
UNCOV
45
          parse_get_name(xml)
1✔
UNCOV
46
        when "get-meta"
UNCOV
47
          parse_get_meta(xml)
1✔
UNCOV
48
        when "get-values"
UNCOV
49
          parse_get_values(xml)
37✔
UNCOV
50
        else
51
          raise "Cannot parse result. Unknow action: #{@action}."
×
UNCOV
52
        end
UNCOV
53
      end
54

55
      # Extracts file information when the request was made with the "action: get-name" parameter
UNCOV
56
      def parse_get_name(xml)
1✔
UNCOV
57
        files = []
1✔
UNCOV
58
        xml.xpath("/response/reply/result/name").each do |node|
1✔
59
          file = Mediaflux::Asset.new(
×
UNCOV
60
            id: node.xpath("./@id").text,
UNCOV
61
            name: node.text,
UNCOV
62
            collection: node.xpath("./@collection").text == "true"
UNCOV
63
          )
64
          files << file
×
UNCOV
65
        end
UNCOV
66
        files
1✔
UNCOV
67
      end
68

69
      # Extracts file information when the request was made with the "action: get-meta" parameter
UNCOV
70
      def parse_get_meta(xml)
1✔
UNCOV
71
        files = []
1✔
UNCOV
72
        xml.xpath("/response/reply/result/asset").each do |node|
1✔
UNCOV
73
          file = Mediaflux::Asset.new(
2✔
UNCOV
74
            id: node.xpath("./@id").text,
UNCOV
75
            name: node.xpath("./name").text,
UNCOV
76
            path: node.xpath("./path").text,
UNCOV
77
            collection: node.xpath("./@collection").text == "true",
UNCOV
78
            size: node.xpath("./content/@total-size").text.to_i,
UNCOV
79
            last_modified_mf: node.xpath("mtime").text
UNCOV
80
          )
UNCOV
81
          files << file
2✔
UNCOV
82
        end
UNCOV
83
        files
1✔
UNCOV
84
      end
85

86
      # Extracts file information when the request was made with the "action: get-values" parameter
87
      # Notice that this code is coupled with the fields defined in QueryRequest.
UNCOV
88
      def parse_get_values(xml)
1✔
UNCOV
89
        files = []
37✔
UNCOV
90
        xml.xpath("/response/reply/result/asset").each do |node|
37✔
UNCOV
91
          file = Mediaflux::Asset.new(
214✔
UNCOV
92
            id: node.xpath("./@id").text,
UNCOV
93
            name: node.xpath("./name").text,
UNCOV
94
            path: node.xpath("./path").text,
UNCOV
95
            collection: node.xpath("./collection").text == "true",
UNCOV
96
            size: node.xpath("./total-size").text.to_i,
UNCOV
97
            last_modified_mf: node.xpath("mtime").text
UNCOV
98
          )
UNCOV
99
          files << file
214✔
UNCOV
100
        end
UNCOV
101
        files
37✔
UNCOV
102
      end
UNCOV
103
  end
UNCOV
104
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