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

pulibrary / tigerdata-app / 319ad2fa-0c00-4104-a2db-87e854d379b7

28 Oct 2025 02:06PM UTC coverage: 88.335% (-3.0%) from 91.294%
319ad2fa-0c00-4104-a2db-87e854d379b7

Pull #2057

circleci

hectorcorrea
Force a change
Pull Request #2057: Dashboard displays projects straights from Mediaflux

12 of 94 new or added lines in 4 files covered. (12.77%)

527 existing lines in 33 files now uncovered.

2711 of 3069 relevant lines covered (88.33%)

408.38 hits per line

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

100.0
/app/models/mediaflux/project_list_request.rb
1
# frozen_string_literal: true
NEW
2
module Mediaflux
3✔
NEW
3
  class ProjectListRequest < Request
3✔
NEW
4
    attr_reader :aql_query, :collection, :action, :deep_search, :iterator
3✔
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
NEW
14
    def initialize(session_token:, aql_query: nil, action: "get-meta", deep_search: true)
3✔
NEW
15
      super(session_token: session_token)
70✔
NEW
16
      @aql_query = aql_query
70✔
NEW
17
      @collection = collection
70✔
NEW
18
      @action = action
70✔
NEW
19
      @deep_search = deep_search
70✔
NEW
20
    end
21

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

28
    # Returns the iterator that could be used to fetch the data
NEW
29
    def results
3✔
NEW
30
      xml = response_xml
70✔
NEW
31
      assets = xml.xpath("/response/reply/result/asset")
70✔
NEW
32
      assets.map do |asset|
70✔
NEW
33
        metadata = asset.xpath("./meta//tigerdata:project", "tigerdata" => "tigerdata")
3,811✔
NEW
34
        {
NEW
35
          mediaflux_id: asset.xpath("@id").first.value,
3,811✔
NEW
36
          title: metadata.xpath("./Title").text,
NEW
37
          description: metadata.xpath("./Description").text,
NEW
38
          project_purpose: metadata.xpath("./ProjectPurpose").text,
NEW
39
          data_sponsor: metadata.xpath("./DataSponsor").text,
NEW
40
          data_manager: metadata.xpath("./DataManager").text,
NEW
41
          data_users: data_users_from_string(metadata.xpath("./DataUser").text),
NEW
42
          directory: metadata.xpath("./ProjectDirectory").text
NEW
43
        }
NEW
44
      end
NEW
45
    end
46

NEW
47
    private
3✔
48

NEW
49
      def build_http_request_body(name:)
3✔
NEW
50
        super do |xml|
140✔
NEW
51
          xml.args do
140✔
NEW
52
            xml.where aql_query if aql_query.present?
140✔
NEW
53
            xml.action action if action.present?
140✔
NEW
54
          end
NEW
55
        end
NEW
56
      end
57

NEW
58
      def data_users_from_string(users)
3✔
NEW
59
        return [] if users.blank?
3,811✔
NEW
60
        users.split(",")
1,020✔
NEW
61
      end
NEW
62
  end
NEW
63
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