wordjelly-auth 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20929f09d0f7a0830bb7e97cb1224a10b2f46563
4
- data.tar.gz: f53281e15c0b96f77f8c9676967d64cbf898509f
3
+ metadata.gz: a718a6cf6f3777261fd7e238201e3136394bd580
4
+ data.tar.gz: 85aa506e330312e5b1bfe0ed8d2e5e501e97685e
5
5
  SHA512:
6
- metadata.gz: 463f324b0c192697443e0bfb8d543ea2d01856cafaf879b7b92b74b6a232f9ee288c4171843f2c285929b8d1289c963ed930f735df4d97f48f5f94c990a657de
7
- data.tar.gz: 256bce6e180cf74349769083eccec13e0e264a59a5bcf2050a9b57c205b7ec10e24b60f27137080cd605d50ba7a687d61378cdf284297348da55e9e722510a13
6
+ metadata.gz: 59aca114451a99d6ea926a7fa4765fc73c2b7208471845d3fb4e57dbf8bb8848d57a7c85ee3f00931304dc668913081df3be92d21c19358d9def6aa398142613
7
+ data.tar.gz: 583172d9e331b87c85addebb0cc2f943ad776494776423c2c3f320cad3d70ef112307adbd34664767c806eb537d71b57913a698dff833595fc52b45e588441ec
data/app/jobs/otp_job.rb CHANGED
@@ -5,7 +5,7 @@ class OtpJob < ActiveJob::Base
5
5
  include Auth::JobExceptionHandler
6
6
 
7
7
  queue_as :default
8
- #self.queue_adapter = Auth.configuration.queue_adapter.to_sym
8
+ self.queue_adapter = :delayed_job
9
9
 
10
10
  ##we currently log all exceptions to redis.
11
11
  rescue_from(StandardError) do |exception|
@@ -126,18 +126,27 @@ module Auth::Concerns::Shopping::ProductConcern
126
126
 
127
127
 
128
128
  minutes.keys.each do |minute|
129
- ## what should be added here ?
130
- ## we will also have to add at those additional minutes.
129
+ #puts "doing minute: #{minute}"
131
130
  products.each do |product|
131
+ #puts "doing product: #{product}"
132
132
  all_cycles_valid = true
133
133
  product.cycles.each do |cycle|
134
- all_cycles_valid = cycle.requirements_satisfied(minute + cycle.time_since_prev_cycle.minutes*60,location_id)
134
+ #puts "doing cycle : #{cycle}"
135
+ all_cycles_valid = cycle.requirements_satisfied(minute + cycle.time_since_prev_cycle.minutes*60,location_id)
136
+ #puts "all cycles valid becomes ------------------------------------------------------------- #{all_cycles_valid.to_s}"
135
137
  end
136
138
  if all_cycles_valid == true
137
139
  product.cycles.each do |cycle|
138
140
  minute_at_which_to_add = minute + cycle.time_since_prev_cycle.minutes*60
141
+ #puts "minute at which to add is: #{minute_at_which_to_add}"
142
+ #puts minutes.keys.to_s
139
143
  if minutes[minute_at_which_to_add]
144
+
140
145
  minutes[minute_at_which_to_add].cycles << cycle
146
+
147
+ #puts "these are the cycles---------"
148
+ #puts minutes[minute_at_which_to_add].cycles.to_s
149
+
141
150
  else
142
151
  raise "necessary minute not in range."
143
152
  end
@@ -146,7 +155,7 @@ module Auth::Concerns::Shopping::ProductConcern
146
155
  end
147
156
  end
148
157
 
149
- puts minutes.to_s
158
+ #puts minutes.to_s
150
159
 
151
160
  minutes
152
161
 
@@ -69,30 +69,79 @@ class Auth::Work::Cycle
69
69
  end
70
70
  end
71
71
 
72
- def requirements_satisfied(minute,location_id)
73
- begin
74
-
72
+ def requirements_satisfied(epoch,location_id)
73
+ #begin
74
+ #puts "came to requirements satisfied"
75
+ Auth.configuration.location_class.constantize.all.each do |l|
76
+ puts l.attributes.to_s
77
+ end
75
78
  location = Auth.configuration.location_class.constantize.find(location_id)
76
79
 
77
- applicable_schedules = Auth::Work::Schedule.where({:minute => minute, :location_id => location_id})
80
+ #puts "location found :#{location}"
81
+ #puts "epoch : #{epoch}, and location id: #{location_id}"
82
+ time_for_query = Time.at(epoch)
83
+ applicable_schedules = Auth::Work::Schedule.collection.find({
84
+ "$and" => [
85
+ {
86
+ "location_id" => location_id
87
+ },
88
+ {
89
+ "start_time" => {
90
+ "$lte" => time_for_query
91
+ }
92
+ },
93
+ {
94
+ "end_time" => {
95
+ "$gte" => time_for_query
96
+ }
97
+ }
98
+ ]
99
+ })
78
100
 
101
+
102
+
103
+ #puts "applicable schedules:"
104
+ #puts applicable_schedules.to_s
105
+
106
+ applicable_schedules = applicable_schedules.to_a
107
+
79
108
  return false if (applicable_schedules.blank? || applicable_schedules.size == 0)
80
109
 
110
+ #puts "there are applicable schedules"
111
+
81
112
  req = self.requirements.deep_dup
113
+ #puts "req are:"
114
+ #puts req.to_s
82
115
 
116
+ applicable_schedules.map!{|c| c = Mongoid::Factory.from_db(Auth::Work::Schedule,c)}
117
+
83
118
  applicable_schedules.each do |schedule|
119
+
84
120
  schedule_for_object = schedule.for_object_class.constantize.find(schedule.for_object_id)
85
- req[schedule_for_object.cycle_type] = req[schedule_for_object.cycle_type] - 1 if req[schedule_for_object.cycle_type]
121
+
122
+ #puts "schedule for object is: #{schedule_for_object}"
123
+
124
+ ## so here the thing is that it can have many cycle types.
125
+
126
+ schedule_for_object.cycle_types.keys.each do |type|
127
+ req[type] = req[type] - 1 if req[type]
128
+ end
129
+
130
+ #puts "req is: #{req}"
131
+
86
132
  end
87
-
88
- true if req.values.uniq[0] == 0
89
- false
133
+
134
+ k = req.values.uniq
90
135
 
91
- rescue
92
136
 
93
- raise "location id provided to cycle does not exist"
137
+ return true if ((k[0] == 0) && (k.size == 1))
138
+ return false
139
+
140
+ #rescue
141
+
142
+ # raise "location id provided to cycle does not exist"
94
143
 
95
- end
144
+ #end
96
145
 
97
146
  end
98
147
 
data/lib/auth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Auth
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -9,8 +9,9 @@ require "typhoeus"
9
9
  require "typhoeus/adapters/faraday"
10
10
  require "elasticsearch"
11
11
  require "mongoid-elasticsearch"
12
+ require "delayed_job_mongoid"
13
+ require "daemons"
12
14
  require "simple_token_authentication"
13
- #require "thin"
14
15
  require "mongoid_versioned_atomic"
15
16
  require "jquery-rails"
16
17
  require "turbolinks"