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

MushroomObserver / mushroom-observer / 14145379140

29 Mar 2025 11:58AM UTC coverage: 84.27% (-9.7%) from 93.985%
14145379140

Pull #2808

github

nimmolo
Handle rss_log content filters with subqueries
Pull Request #2808: Convert Query to AR scopes

477 of 2306 new or added lines in 78 files covered. (20.69%)

1381 existing lines in 27 files now uncovered.

26562 of 31520 relevant lines covered (84.27%)

536.24 hits per line

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

95.45
/app/classes/query/scope_modules/sequence_operators.rb
1
# frozen_string_literal: true
2

3
# methods for moving forward/back up/down in Query results
4
module Query::ScopeModules::SequenceOperators
1✔
5
  # Current place in results, as an id.  (Returns nil if not set yet.)
6
  attr_reader :current_id
1✔
7

8
  # Set current place in results; takes id (String or Integer).
9
  def current_id=(id)
1✔
10
    @save_current_id = @current_id = id.to_s.to_i
56✔
11
  end
12

13
  # Reset current place in results to place last given in a "current=" call.
14
  def reset
1✔
15
    @current_id = @save_current_id
1✔
16
  end
17

18
  # Current place in results, instantiated.  (Returns nil if not set yet.)
19
  def current(*)
1✔
20
    @current_id ? instantiate_results([@current_id], *).first : nil
5✔
21
  end
22

23
  # Set current place in results; takes instance or id (String or Integer).
24
  def current=(arg)
1✔
25
    if arg.is_a?(model)
55✔
26
      @results ||= {}
54✔
27
      @results[arg.id] = arg
54✔
28
      self.current_id = arg.id
54✔
29
    else
30
      self.current_id = arg
1✔
31
    end
32
  end
33

34
  # Move to first place.
35
  def first
1✔
36
    new_self = self
2✔
37
    id = new_self.result_ids.first
2✔
38
    if id.positive?
2✔
39
      @current_id = id
2✔
40
    else
NEW
41
      new_self = nil
×
42
    end
43
    new_self
2✔
44
  end
45

46
  # Move to previous place.
47
  def prev
1✔
48
    new_self = self
26✔
49
    index = result_ids.index(current_id)
26✔
50
    return nil unless index
26✔
51

52
    if index.positive?
26✔
53
      @current_id = result_ids[index - 1]
22✔
54
    else
55
      new_self = nil
4✔
56
    end
57
    new_self
26✔
58
  end
59

60
  # Move to next place.
61
  def next
1✔
62
    new_self = self
30✔
63
    index = result_ids.index(current_id)
30✔
64
    return nil unless index
30✔
65

66
    if index < result_ids.length - 1
30✔
67
      @current_id = result_ids[index + 1]
26✔
68
    else
69
      new_self = nil
4✔
70
    end
71
    new_self
30✔
72
  end
73

74
  # Move to last place.
75
  def last
1✔
76
    new_self = self
2✔
77
    id = new_self.result_ids.last
2✔
78
    if id.positive?
2✔
79
      @current_id = id
2✔
80
    else
NEW
81
      new_self = nil
×
82
    end
83
    new_self
2✔
84
  end
85
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

© 2026 Coveralls, Inc