Module: Poms::Views

Extended by:
Views
Includes:
Connect
Included in:
Poms, Views
Defined in:
lib/poms/views.rb

Overview

Views constructs the urls that can be used to access specific views in POMS.

Instance Method Summary collapse

Methods included from Connect

#get_json

Instance Method Details

#broadcasts_by_channel_and_start(channel, start_time = Time.now, end_time = 1.day.ago, limit = 1, descending = true) ⇒ Object

rubocop:disable Metrics/MethodLength



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/poms/views.rb', line 24

def broadcasts_by_channel_and_start(channel, start_time = Time.now,
                                    end_time = 1.day.ago, limit = 1,
                                    descending = true)
  args = {
    startkey: "[\"#{channel}\", #{to_poms_timestamp(start_time)}]",
    endkey: "[\"#{channel}\", #{to_poms_timestamp(end_time)}]",
    limit: limit,
    descending: descending,
    reduce: false,
    include_docs: true
  }
  construct_view_url('broadcasts-by-channel-and-start', args)
end

#by_group(mid) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/poms/views.rb', line 14

def by_group(mid)
  args = {
    key: "\"#{mid}\"",
    reduce: false,
    include_docs: true
  }
  construct_view_url('by-group', args)
end

#get(mid) ⇒ Object



9
10
11
12
# File 'lib/poms/views.rb', line 9

def get(mid)
  uri = "#{base_url}/media/#{mid}"
  get_json(uri)
end