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

pulibrary / tigerdata-app / 751a8b7a-3dcf-4fbf-b16e-522d27f88642

03 Nov 2025 02:30PM UTC coverage: 91.4% (+0.006%) from 91.394%
751a8b7a-3dcf-4fbf-b16e-522d27f88642

push

circleci

web-flow
Make sure all projects are fetched (not only the first 100) (#2131)

This fixes an issue we noted while testing in Staging since
Administrators should be able to fetch all projects that they have
access to, not only the first 100 (which is the default when not
indicating a `size` parameter to Mediaflux.)

3 of 3 new or added lines in 1 file covered. (100.0%)

191 existing lines in 11 files now uncovered.

2827 of 3093 relevant lines covered (91.4%)

486.73 hits per line

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

100.0
/app/models/mediaflux/asset.rb
1
# frozen_string_literal: true
UNCOV
2
module Mediaflux
3✔
UNCOV
3
  class Asset
3✔
UNCOV
4
    attr_accessor :id, :path, :collection, :size
3✔
5

UNCOV
6
    def initialize(id:, name:, collection:, path: nil, last_modified_mf: nil, size: nil)
3✔
UNCOV
7
      @id = id
223✔
UNCOV
8
      @name = name
223✔
UNCOV
9
      @path = path
223✔
UNCOV
10
      @collection = collection
223✔
UNCOV
11
      @size = size
223✔
UNCOV
12
      @last_modified_mf = last_modified_mf
223✔
UNCOV
13
    end
14

UNCOV
15
    def name
3✔
16
      # Mediaflux supports the concept of files without a name and in those cases the
17
      # "name" property might be empty, but the actual name assigned internally by
18
      # Mediaflux (e.g. __asset_id__4665) is still reflected in the path.
19
      if @name == ""
184✔
20
        Pathname.new(path).basename.to_s
166✔
UNCOV
21
      else
22
        @name
18✔
UNCOV
23
      end
UNCOV
24
    end
25

26
    # Returns the path to the asset but without the root collection namespace as part of it.
27
    #
28
    # Example:
29
    #   path        -> "/tigerdata/projectg/folder1/file-abc.txt"
30
    #   path_short  -> "/projectg/folder1/file-abc.txt"
UNCOV
31
    def path_short
3✔
UNCOV
32
      return nil if path.nil?
180✔
UNCOV
33
      if path.starts_with?(Mediaflux::Connection.root_collection_namespace)
180✔
UNCOV
34
        path[Mediaflux::Connection.root_collection_namespace.length..-1]
4✔
UNCOV
35
      else
36
        path
176✔
UNCOV
37
      end
UNCOV
38
    end
39

40
    # Returns the last modified date but using the standard ISO 8601 (https://en.wikipedia.org/wiki/ISO_8601)
UNCOV
41
    def last_modified
3✔
UNCOV
42
      return nil if @last_modified_mf.nil?
179✔
43
      # https://nandovieira.com/working-with-dates-on-ruby-on-rails
44
      # Mediaflux dates are in UTC and look like this "07-Feb-2024 21:48:01"
UNCOV
45
      Object::Time.zone.parse(@last_modified_mf).in_time_zone("America/New_York").iso8601
179✔
UNCOV
46
    end
47

48
    # Returns the path for the asset
49
    # For a collection returns the path_short, but for a file is the dirname of the path_short
50
    #
51
    # Example for a file:
52
    #   path        -> "/tigerdata/projectg/folder1/file-abc.txt"
53
    #   path_short  -> "/projectg/folder1/file-abc.txt"
54
    #   path_only  -> "/projectg/folder1"
55
    # Example for a collection:
56
    #   path        -> "/tigerdata/projectg/folder1"
57
    #   path_short  -> "/projectg/folder1"
58
    #   path_only  -> "/projectg/folder1"
UNCOV
59
    def path_only
3✔
UNCOV
60
      return nil if path.nil?
178✔
UNCOV
61
      if collection
178✔
UNCOV
62
        path_short
1✔
UNCOV
63
      else
UNCOV
64
        p = Pathname.new(path_short)
177✔
UNCOV
65
        p.dirname.to_s
177✔
UNCOV
66
      end
UNCOV
67
    end
UNCOV
68
  end
UNCOV
69
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