Module: Queries::Concerns::Tags

Extended by:
ActiveSupport::Concern
Defined in:
lib/queries/concerns/tags.rb

Overview

Helpers for queries that reference Identifier

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) keyword_ids

Returns the value of attribute keyword_ids



6
7
8
# File 'lib/queries/concerns/tags.rb', line 6

def keyword_ids
  @keyword_ids
end

Instance Method Details

- (Object) matching_keyword_ids



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/queries/concerns/tags.rb', line 13

def matching_keyword_ids
  return nil if keyword_ids.empty?
  o = table
  t = ::Tag.arel_table

  a = o.alias("a_")
  b = o.project(a[Arel.star]).from(a)

  c = t.alias('t1')

  b = b.join(c, Arel::Nodes::OuterJoin)
    .on(
      a[:id].eq(c[:tag_object_id])
    .and(c[:tag_object_type].eq(table.name.classify))
  )

  e = c[:keyword_id].not_eq(nil)
  f = c[:keyword_id].eq_any(keyword_ids)

  b = b.where(e.and(f))
  b = b.group(a['id'])
  b = b.as('tz5_')

  _a = table.joins(Arel::Nodes::InnerJoin.new(b, Arel::Nodes::On.new(b['id'].eq(o['id']))))
end

- (Arel::Table) tag_table

Returns:

  • (Arel::Table)


9
10
11
# File 'lib/queries/concerns/tags.rb', line 9

def tag_table 
  ::Tag.arel_table
end