Class: WinewooCore::Repositories::Mongo::Queries::ProducerQuery
- Inherits:
-
UserQuery
show all
- Defined in:
- lib/winewoo_core/repositories/mongo/queries/producer_query.rb
Instance Method Summary
collapse
Methods inherited from UserQuery
#with_role
#method_missing, #respond_to?, #respond_to_missing?
Constructor Details
Returns a new instance of ProducerQuery.
5
6
7
|
# File 'lib/winewoo_core/repositories/mongo/queries/producer_query.rb', line 5
def initialize
super User.where(user_roles: :producer)
end
|
Instance Method Details
#from_interpro(interpro_id) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/winewoo_core/repositories/mongo/queries/producer_query.rb', line 10
def from_interpro(interpro_id)
@relation = @relation
.where(interpro_ids: interpro_id)
block_given? ?
@relation.each { |user| yield user } :
self
end
|
#not_connected_yet ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'lib/winewoo_core/repositories/mongo/queries/producer_query.rb', line 68
def not_connected_yet
@relation = @relation
.where(:sign_in_count => 0)
block_given? ?
@relation.each { |user| yield user } :
self
end
|
#not_in(producer_ids) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/winewoo_core/repositories/mongo/queries/producer_query.rb', line 20
def not_in(producer_ids)
@relation = @relation
.where(:_id.nin => producer_ids)
block_given? ?
@relation.each { |user| yield user } :
self
end
|
#with_auto_generated_estate ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/winewoo_core/repositories/mongo/queries/producer_query.rb', line 57
def with_auto_generated_estate
@relation = @relation
.where(:estates.elem_match =>
{ company: /Propriété : /i})
block_given? ?
@relation.each { |user| yield user } :
self
end
|
#without_estates ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/winewoo_core/repositories/mongo/queries/producer_query.rb', line 30
def without_estates
@relation = @relation
.where(:estates.exists => false)
block_given? ?
@relation.each { |user| yield user } :
self
end
|
#without_wines(interpro_id) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/winewoo_core/repositories/mongo/queries/producer_query.rb', line 40
def without_wines(interpro_id)
producer_ids = WinewooCore::Repositories::Mongo::Queries::WineQuery
.new
.officials
.from_interpro(interpro_id)
.unscoped
.distinct(:producer_id)
@relation = @relation
.where(:_id.nin => producer_ids)
block_given? ?
@relation.each { |user| yield user } :
self
end
|