enju_circulation 0.1.0.pre35 → 0.1.0.pre36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/manifestation_checkout_stats_controller.rb +3 -0
- data/app/controllers/manifestation_reserve_stats_controller.rb +3 -0
- data/app/controllers/user_checkout_stats_controller.rb +3 -0
- data/app/controllers/user_reserve_stats_controller.rb +3 -0
- data/app/models/manifestation_checkout_stat.rb +22 -12
- data/app/models/manifestation_checkout_stat_state_machine.rb +18 -0
- data/app/models/manifestation_checkout_stat_transition.rb +7 -0
- data/app/models/manifestation_reserve_stat.rb +22 -12
- data/app/models/manifestation_reserve_stat_state_machine.rb +18 -0
- data/app/models/manifestation_reserve_stat_transition.rb +7 -0
- data/app/models/user_checkout_stat.rb +23 -13
- data/app/models/user_checkout_stat_state_machine.rb +18 -0
- data/app/models/user_checkout_stat_transition.rb +7 -0
- data/app/models/user_reserve_stat.rb +23 -13
- data/app/models/user_reserve_stat_state_machine.rb +18 -0
- data/app/models/user_reserve_stat_transition.rb +7 -0
- data/app/views/carrier_type_has_checkout_types/edit.html.erb +2 -2
- data/app/views/carrier_type_has_checkout_types/index.html.erb +12 -5
- data/app/views/carrier_type_has_checkout_types/new.html.erb +2 -2
- data/app/views/carrier_type_has_checkout_types/show.html.erb +5 -3
- data/app/views/checked_items/index.html.erb +2 -2
- data/app/views/checked_items/new.html.erb +2 -2
- data/app/views/checked_items/show.html.erb +2 -2
- data/app/views/checkins/edit.html.erb +2 -2
- data/app/views/checkins/index.html.erb +2 -2
- data/app/views/checkins/new.html.erb +2 -2
- data/app/views/checkins/show.html.erb +2 -2
- data/app/views/checkout_stat_has_manifestations/edit.html.erb +2 -2
- data/app/views/checkout_stat_has_manifestations/index.html.erb +2 -2
- data/app/views/checkout_stat_has_manifestations/new.html.erb +2 -2
- data/app/views/checkout_stat_has_manifestations/show.html.erb +2 -2
- data/app/views/checkout_stat_has_users/edit.html.erb +2 -2
- data/app/views/checkout_stat_has_users/index.html.erb +2 -2
- data/app/views/checkout_stat_has_users/new.html.erb +2 -2
- data/app/views/checkout_stat_has_users/show.html.erb +2 -2
- data/app/views/checkout_types/edit.html.erb +2 -2
- data/app/views/checkout_types/index.html.erb +2 -2
- data/app/views/checkout_types/new.html.erb +2 -2
- data/app/views/checkout_types/show.html.erb +2 -2
- data/app/views/checkouts/_index.html.erb +2 -2
- data/app/views/checkouts/_index_item.html.erb +2 -2
- data/app/views/checkouts/_index_overdue.html.erb +2 -2
- data/app/views/checkouts/_index_user.html.erb +2 -2
- data/app/views/checkouts/edit.html.erb +2 -2
- data/app/views/checkouts/show.html.erb +2 -2
- data/app/views/circulation_statuses/edit.html.erb +2 -2
- data/app/views/circulation_statuses/index.html.erb +2 -2
- data/app/views/circulation_statuses/new.html.erb +2 -2
- data/app/views/circulation_statuses/show.html.erb +2 -2
- data/app/views/item_has_use_restrictions/show.html.erb +2 -2
- data/app/views/lending_policies/edit.html.erb +2 -2
- data/app/views/lending_policies/index.html.erb +2 -2
- data/app/views/lending_policies/new.html.erb +2 -2
- data/app/views/lending_policies/show.html.erb +2 -2
- data/app/views/manifestation_checkout_stats/_form.html.erb +2 -1
- data/app/views/manifestation_checkout_stats/edit.html.erb +2 -2
- data/app/views/manifestation_checkout_stats/index.html.erb +3 -3
- data/app/views/manifestation_checkout_stats/new.html.erb +2 -2
- data/app/views/manifestation_checkout_stats/show.html.erb +5 -3
- data/app/views/manifestation_reserve_stats/_form.html.erb +2 -1
- data/app/views/manifestation_reserve_stats/edit.html.erb +2 -2
- data/app/views/manifestation_reserve_stats/index.html.erb +3 -3
- data/app/views/manifestation_reserve_stats/new.html.erb +2 -2
- data/app/views/manifestation_reserve_stats/show.html.erb +5 -3
- data/app/views/reserve_stat_has_manifestations/edit.html.erb +2 -2
- data/app/views/reserve_stat_has_manifestations/index.html.erb +2 -2
- data/app/views/reserve_stat_has_manifestations/new.html.erb +2 -2
- data/app/views/reserve_stat_has_manifestations/show.html.erb +2 -2
- data/app/views/reserve_stat_has_users/edit.html.erb +2 -2
- data/app/views/reserve_stat_has_users/index.html.erb +2 -2
- data/app/views/reserve_stat_has_users/new.html.erb +2 -2
- data/app/views/reserve_stat_has_users/show.html.erb +2 -2
- data/app/views/reserves/_new.html.erb +2 -2
- data/app/views/reserves/_new_user.html.erb +2 -2
- data/app/views/reserves/edit.html.erb +2 -2
- data/app/views/reserves/index.html.erb +3 -3
- data/app/views/reserves/show.html.erb +2 -2
- data/app/views/use_restrictions/edit.html.erb +2 -2
- data/app/views/use_restrictions/index.html.erb +2 -2
- data/app/views/use_restrictions/new.html.erb +2 -2
- data/app/views/use_restrictions/show.html.erb +2 -2
- data/app/views/user_checkout_stats/_form.html.erb +2 -1
- data/app/views/user_checkout_stats/edit.html.erb +2 -2
- data/app/views/user_checkout_stats/index.html.erb +3 -3
- data/app/views/user_checkout_stats/new.html.erb +2 -2
- data/app/views/user_checkout_stats/show.html.erb +5 -3
- data/app/views/user_group_has_checkout_types/edit.html.erb +2 -2
- data/app/views/user_group_has_checkout_types/index.html.erb +11 -5
- data/app/views/user_group_has_checkout_types/new.html.erb +2 -2
- data/app/views/user_group_has_checkout_types/show.html.erb +5 -3
- data/app/views/user_reserve_stats/_form.html.erb +2 -1
- data/app/views/user_reserve_stats/edit.html.erb +2 -2
- data/app/views/user_reserve_stats/index.html.erb +3 -3
- data/app/views/user_reserve_stats/new.html.erb +2 -2
- data/app/views/user_reserve_stats/show.html.erb +5 -3
- data/app/workers/manifestation_checkout_stat_queue.rb +7 -0
- data/app/workers/manifestation_reserve_stat_queue.rb +7 -0
- data/app/workers/user_checkout_stat_queue.rb +7 -0
- data/app/workers/user_reserve_stat_queue.rb +7 -0
- data/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +14 -0
- data/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +14 -0
- data/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +14 -0
- data/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +14 -0
- data/lib/enju_circulation/engine.rb +1 -0
- data/lib/enju_circulation/version.rb +1 -1
- data/lib/generators/enju_circulation/setup/setup_generator.rb +7 -0
- data/lib/generators/enju_circulation/setup/templates/config/schedule.rb +0 -4
- data/spec/controllers/checked_items_controller_spec.rb +7 -7
- data/spec/controllers/checkins_controller_spec.rb +3 -3
- data/spec/controllers/checkouts_controller_spec.rb +4 -4
- data/spec/controllers/reserves_controller_spec.rb +5 -5
- data/spec/dummy/config/initializers/statesman.rb +3 -0
- data/spec/dummy/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +11 -0
- data/spec/dummy/db/schema.rb +50 -2
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/models/checked_item_spec.rb +1 -1
- data/spec/models/checkout_spec.rb +5 -5
- data/spec/models/manifestation_checkout_stat_spec.rb +5 -1
- data/spec/models/manifestation_reserve_stat_spec.rb +5 -1
- data/spec/models/reserve_spec.rb +11 -11
- data/spec/models/user_checkout_stat_spec.rb +5 -1
- data/spec/models/user_group_has_checkout_type_spec.rb +2 -2
- data/spec/models/user_reserve_stat_spec.rb +5 -1
- data/spec/spec_helper.rb +3 -0
- data/spec/support/resque.rb +30 -0
- metadata +74 -120
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/solr/conf/admin-extra.html +0 -31
- data/spec/dummy/solr/conf/elevate.xml +0 -36
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +0 -246
- data/spec/dummy/solr/conf/protwords.txt +0 -21
- data/spec/dummy/solr/conf/schema.xml +0 -255
- data/spec/dummy/solr/conf/scripts.conf +0 -24
- data/spec/dummy/solr/conf/solrconfig.xml +0 -667
- data/spec/dummy/solr/conf/spellings.txt +0 -2
- data/spec/dummy/solr/conf/stopwords.txt +0 -58
- data/spec/dummy/solr/conf/synonyms.txt +0 -31
- data/spec/dummy/solr/default/data/index/_6ox.fdt +0 -0
- data/spec/dummy/solr/default/data/index/_6ox.fdx +0 -0
- data/spec/dummy/solr/default/data/index/_6ox.fnm +0 -0
- data/spec/dummy/solr/default/data/index/_6ox.nvd +0 -0
- data/spec/dummy/solr/default/data/index/_6ox.nvm +0 -0
- data/spec/dummy/solr/default/data/index/_6ox.si +0 -0
- data/spec/dummy/solr/default/data/index/_6ox_Lucene41_0.doc +0 -0
- data/spec/dummy/solr/default/data/index/_6ox_Lucene41_0.pos +0 -0
- data/spec/dummy/solr/default/data/index/_6ox_Lucene41_0.tim +0 -0
- data/spec/dummy/solr/default/data/index/_6ox_Lucene41_0.tip +0 -0
- data/spec/dummy/solr/default/data/index/segments.gen +0 -0
- data/spec/dummy/solr/default/data/index/segments_ajk +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013653 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013654 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013655 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013656 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013657 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013658 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013659 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013660 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013661 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000013662 +0 -0
- data/spec/dummy/solr/development/data/index/segments.gen +0 -0
- data/spec/dummy/solr/development/data/index/segments_1 +0 -0
- data/spec/dummy/solr/solr.xml +0 -8
- data/spec/dummy/solr/test/data/index/segments.gen +0 -0
- data/spec/dummy/solr/test/data/index/segments_1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0440b81b0aae840cf287a686585a8cec +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1572dfd6f1e555f4be1aa60ddc3cb0c0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2ffe508d0533d0afd2a37bb574eda40d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/49d32c13d390c1b80d8b2705aac86579 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4aa18096a209e515f5f1df487622cdf4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6fcdd2234a7c25f9d4179ca12fd9f7b4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/aa2e1ada35daa496bb08e85fcb817536 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c1ab0ecf3cf57db41d9e4cd9306d8829 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e9738177de2083b68d42e053a1529244 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e9ce2df3f0160329df69b22a911dbd04 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ac2bb251a86ff777bafffb66cece6b55979f1e5
|
4
|
+
data.tar.gz: d1127764b351b070b1ab3340a0a49ac6ff13d9ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 924e8d7feff2b2a0c33d5b088d7764df1370b43fd0f7d08d8332e5558b2e1cba9293055d797b1676e5d7db9a87c1b790d85a3987638e0a8694fb509d007d9275
|
7
|
+
data.tar.gz: 2eb473efe2c8755157e9660f0ecc8b77a9ad1b3d39484044c6674e0074d7be47692ad73ab2494ca011d40a06c81e9c0fb948cea9780c17fd256762cd68ec4aeb
|
@@ -66,6 +66,9 @@ class ManifestationCheckoutStatsController < ApplicationController
|
|
66
66
|
def update
|
67
67
|
respond_to do |format|
|
68
68
|
if @manifestation_checkout_stat.update_attributes(params[:manifestation_checkout_stat])
|
69
|
+
if @manifestation_checkout_stat.mode == 'import'
|
70
|
+
Resque.enqueue(ManifestationCheckoutStatQueue, @manifestation_checkout_stat.id)
|
71
|
+
end
|
69
72
|
format.html { redirect_to @manifestation_checkout_stat, :notice => t('controller.successfully_updated', :model => t('activerecord.models.manifestation_checkout_stat')) }
|
70
73
|
format.json { head :no_content }
|
71
74
|
else
|
@@ -66,6 +66,9 @@ class ManifestationReserveStatsController < ApplicationController
|
|
66
66
|
def update
|
67
67
|
respond_to do |format|
|
68
68
|
if @manifestation_reserve_stat.update_attributes(params[:manifestation_reserve_stat])
|
69
|
+
if @manifestation_reserve_stat.mode == 'import'
|
70
|
+
Resque.enqueue(ManifestationReserveStatQueue, @manifestation_reserve_stat.id)
|
71
|
+
end
|
69
72
|
format.html { redirect_to @manifestation_reserve_stat, :notice => t('controller.successfully_created', :model => t('activerecord.models.manifestation_reserve_stat')) }
|
70
73
|
format.json { head :no_content }
|
71
74
|
else
|
@@ -66,6 +66,9 @@ class UserCheckoutStatsController < ApplicationController
|
|
66
66
|
def update
|
67
67
|
respond_to do |format|
|
68
68
|
if @user_checkout_stat.update_attributes(params[:user_checkout_stat])
|
69
|
+
if @user_checkout_stat.mode == 'import'
|
70
|
+
Resque.enqueue(UserCheckoutStatQueue, @user_checkout_stat.id)
|
71
|
+
end
|
69
72
|
format.html { redirect_to @user_checkout_stat, :notice => t('controller.successfully_updated', :model => t('activerecord.models.user_checkout_stat')) }
|
70
73
|
format.json { head :no_content }
|
71
74
|
else
|
@@ -66,6 +66,9 @@ class UserReserveStatsController < ApplicationController
|
|
66
66
|
def update
|
67
67
|
respond_to do |format|
|
68
68
|
if @user_reserve_stat.update_attributes(params[:user_reserve_stat])
|
69
|
+
if @user_reserve_stat.mode == 'import'
|
70
|
+
Resque.enqueue(UserReserveStatQueue, @user_reserve_stat.id)
|
71
|
+
end
|
69
72
|
format.html { redirect_to @user_reserve_stat, :notice => t('controller.successfully_updated', :model => t('activerecord.models.user_reserve_stat')) }
|
70
73
|
format.json { head :no_content }
|
71
74
|
else
|
@@ -1,34 +1,44 @@
|
|
1
1
|
class ManifestationCheckoutStat < ActiveRecord::Base
|
2
|
-
|
2
|
+
include Statesman::Adapters::ActiveRecordModel
|
3
3
|
include CalculateStat
|
4
|
-
|
5
|
-
|
4
|
+
attr_accessible :start_date, :end_date, :note, :mode
|
5
|
+
default_scope {order('manifestation_checkout_stats.id DESC')}
|
6
|
+
scope :not_calculated, -> {in_state(:pending)}
|
6
7
|
has_many :checkout_stat_has_manifestations
|
7
8
|
has_many :manifestations, :through => :checkout_stat_has_manifestations
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
paginates_per 10
|
11
|
+
attr_accessor :mode
|
12
|
+
|
13
|
+
has_many :manifestation_checkout_stat_transitions
|
14
|
+
|
15
|
+
def state_machine
|
16
|
+
ManifestationCheckoutStatStateMachine.new(self, transition_class: ManifestationCheckoutStatTransition)
|
14
17
|
end
|
15
18
|
|
16
|
-
|
19
|
+
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
|
20
|
+
to: :state_machine
|
17
21
|
|
18
|
-
def calculate_count
|
22
|
+
def calculate_count!
|
19
23
|
self.started_at = Time.zone.now
|
20
24
|
Manifestation.find_each do |manifestation|
|
21
|
-
daily_count = Checkout.manifestations_count(
|
25
|
+
daily_count = Checkout.manifestations_count(start_date.beginning_of_day, end_date.tomorrow.beginning_of_day, manifestation)
|
22
26
|
#manifestation.update_attributes({:daily_checkouts_count => daily_count, :total_count => manifestation.total_count + daily_count})
|
23
27
|
if daily_count > 0
|
24
28
|
self.manifestations << manifestation
|
25
29
|
sql = ['UPDATE checkout_stat_has_manifestations SET checkouts_count = ? WHERE manifestation_checkout_stat_id = ? AND manifestation_id = ?', daily_count, self.id, manifestation.id]
|
26
|
-
|
30
|
+
ManifestationCheckoutStat.connection.execute(
|
27
31
|
self.class.send(:sanitize_sql_array, sql)
|
28
32
|
)
|
29
33
|
end
|
30
34
|
end
|
31
35
|
self.completed_at = Time.zone.now
|
36
|
+
transition_to!(:completed)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def self.transition_class
|
41
|
+
ManifestationCheckoutStatTransition
|
32
42
|
end
|
33
43
|
end
|
34
44
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ManifestationCheckoutStatStateMachine
|
2
|
+
include Statesman::Machine
|
3
|
+
state :pending, initial: true
|
4
|
+
state :started
|
5
|
+
state :completed
|
6
|
+
|
7
|
+
transition from: :pending, to: :started
|
8
|
+
transition from: :started, to: :completed
|
9
|
+
|
10
|
+
after_transition(to: :started) do |manifestation_checkout_stat|
|
11
|
+
manifestation_checkout_stat.update_column(:started_at, Time.zone.now)
|
12
|
+
manifestation_checkout_stat.calculate_count!
|
13
|
+
end
|
14
|
+
|
15
|
+
after_transition(to: :completed) do |manifestation_checkout_stat|
|
16
|
+
manifestation_checkout_stat.update_column(:completed_at, Time.zone.now)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class ManifestationCheckoutStatTransition < ActiveRecord::Base
|
2
|
+
include Statesman::Adapters::ActiveRecordTransition
|
3
|
+
|
4
|
+
|
5
|
+
belongs_to :manifestation_cehckout_stat, inverse_of: :manifestation_checkout_stat_transitions
|
6
|
+
attr_accessible :to_state, :sort_key, :metadata
|
7
|
+
end
|
@@ -1,34 +1,44 @@
|
|
1
1
|
class ManifestationReserveStat < ActiveRecord::Base
|
2
|
-
|
2
|
+
include Statesman::Adapters::ActiveRecordModel
|
3
3
|
include CalculateStat
|
4
|
-
|
5
|
-
|
4
|
+
attr_accessible :start_date, :end_date, :note, :mode
|
5
|
+
default_scope {order('manifestation_reserve_stats.id DESC')}
|
6
|
+
scope :not_calculated, -> {in_state(:pending)}
|
6
7
|
has_many :reserve_stat_has_manifestations
|
7
8
|
has_many :manifestations, :through => :reserve_stat_has_manifestations
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
paginates_per 10
|
11
|
+
attr_accessor :mode
|
12
|
+
|
13
|
+
has_many :manifestation_reserve_stat_transitions
|
14
|
+
|
15
|
+
def state_machine
|
16
|
+
ManifestationReserveStatStateMachine.new(self, transition_class: ManifestationReserveStatTransition)
|
14
17
|
end
|
15
18
|
|
16
|
-
|
19
|
+
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
|
20
|
+
to: :state_machine
|
17
21
|
|
18
|
-
def calculate_count
|
22
|
+
def calculate_count!
|
19
23
|
self.started_at = Time.zone.now
|
20
24
|
Manifestation.find_each do |manifestation|
|
21
|
-
daily_count = manifestation.reserves.created(
|
25
|
+
daily_count = manifestation.reserves.created(start_date.beginning_of_day, end_date.tomorrow.beginning_of_day).size
|
22
26
|
#manifestation.update_attributes({:daily_reserves_count => daily_count, :total_count => manifestation.total_count + daily_count})
|
23
27
|
if daily_count > 0
|
24
28
|
self.manifestations << manifestation
|
25
29
|
sql = ['UPDATE reserve_stat_has_manifestations SET reserves_count = ? WHERE manifestation_reserve_stat_id = ? AND manifestation_id = ?', daily_count, self.id, manifestation.id]
|
26
|
-
|
30
|
+
ManifestationReserveStat.connection.execute(
|
27
31
|
self.class.send(:sanitize_sql_array, sql)
|
28
32
|
)
|
29
33
|
end
|
30
34
|
end
|
31
35
|
self.completed_at = Time.zone.now
|
36
|
+
transition_to!(:completed)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def self.transition_class
|
41
|
+
ManifestationReserveStatTransition
|
32
42
|
end
|
33
43
|
end
|
34
44
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ManifestationReserveStatStateMachine
|
2
|
+
include Statesman::Machine
|
3
|
+
state :pending, initial: true
|
4
|
+
state :started
|
5
|
+
state :completed
|
6
|
+
|
7
|
+
transition from: :pending, to: :started
|
8
|
+
transition from: :started, to: :completed
|
9
|
+
|
10
|
+
after_transition(to: :started) do |manifestation_reserve_stat|
|
11
|
+
manifestation_reserve_stat.update_column(:started_at, Time.zone.now)
|
12
|
+
manifestation_reserve_stat.calculate_count!
|
13
|
+
end
|
14
|
+
|
15
|
+
after_transition(to: :completed) do |manifestation_reserve_stat|
|
16
|
+
manifestation_reserve_stat.update_column(:completed_at, Time.zone.now)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class ManifestationReserveStatTransition < ActiveRecord::Base
|
2
|
+
include Statesman::Adapters::ActiveRecordTransition
|
3
|
+
|
4
|
+
|
5
|
+
belongs_to :manifestation_reserve_stat, inverse_of: :manifestation_reserve_stat_transitions
|
6
|
+
attr_accessible :to_state, :sort_key, :metadata
|
7
|
+
end
|
@@ -1,33 +1,43 @@
|
|
1
1
|
class UserCheckoutStat < ActiveRecord::Base
|
2
|
-
|
2
|
+
include Statesman::Adapters::ActiveRecordModel
|
3
3
|
include CalculateStat
|
4
|
-
|
5
|
-
|
4
|
+
attr_accessible :start_date, :end_date, :note, :mode
|
5
|
+
default_scope {order('user_checkout_stats.id DESC')}
|
6
|
+
scope :not_calculated, -> {in_state(:pending)}
|
6
7
|
has_many :checkout_stat_has_users
|
7
8
|
has_many :users, :through => :checkout_stat_has_users
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
paginates_per 10
|
11
|
+
attr_accessor :mode
|
12
|
+
|
13
|
+
has_many :user_checkout_stat_transitions
|
14
|
+
|
15
|
+
def state_machine
|
16
|
+
UserCheckoutStatStateMachine.new(self, transition_class: UserCheckoutStatTransition)
|
14
17
|
end
|
15
18
|
|
16
|
-
|
19
|
+
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
|
20
|
+
to: :state_machine
|
17
21
|
|
18
|
-
def calculate_count
|
22
|
+
def calculate_count!
|
19
23
|
self.started_at = Time.zone.now
|
20
24
|
User.find_each do |user|
|
21
|
-
daily_count = user.checkouts.completed(
|
25
|
+
daily_count = user.checkouts.completed(start_date.beginning_of_day, end_date.tomorrow.beginning_of_day).size
|
22
26
|
if daily_count > 0
|
23
27
|
self.users << user
|
24
|
-
sql = ['UPDATE checkout_stat_has_users SET checkouts_count = ? WHERE user_checkout_stat_id = ? AND user_id = ?', daily_count,
|
25
|
-
|
28
|
+
sql = ['UPDATE checkout_stat_has_users SET checkouts_count = ? WHERE user_checkout_stat_id = ? AND user_id = ?', daily_count, id, user.id]
|
29
|
+
UserCheckoutStat.connection.execute(
|
26
30
|
self.class.send(:sanitize_sql_array, sql)
|
27
31
|
)
|
28
32
|
end
|
29
33
|
end
|
30
34
|
self.completed_at = Time.zone.now
|
35
|
+
transition_to!(:completed)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def self.transition_class
|
40
|
+
UserCheckoutStatTransition
|
31
41
|
end
|
32
42
|
end
|
33
43
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class UserCheckoutStatStateMachine
|
2
|
+
include Statesman::Machine
|
3
|
+
state :pending, initial: true
|
4
|
+
state :started
|
5
|
+
state :completed
|
6
|
+
|
7
|
+
transition from: :pending, to: :started
|
8
|
+
transition from: :started, to: :completed
|
9
|
+
|
10
|
+
after_transition(to: :started) do |user_checkout_stat|
|
11
|
+
user_checkout_stat.update_column(:started_at, Time.zone.now)
|
12
|
+
user_checkout_stat.calculate_count!
|
13
|
+
end
|
14
|
+
|
15
|
+
after_transition(to: :completed) do |user_checkout_stat|
|
16
|
+
user_checkout_stat.update_column(:completed_at, Time.zone.now)
|
17
|
+
end
|
18
|
+
end
|
@@ -1,33 +1,43 @@
|
|
1
1
|
class UserReserveStat < ActiveRecord::Base
|
2
|
-
|
2
|
+
include Statesman::Adapters::ActiveRecordModel
|
3
3
|
include CalculateStat
|
4
|
-
|
5
|
-
|
4
|
+
attr_accessible :start_date, :end_date, :note, :mode
|
5
|
+
default_scope {order('user_reserve_stats.id DESC')}
|
6
|
+
scope :not_calculated, -> {in_state(:pending)}
|
6
7
|
has_many :reserve_stat_has_users
|
7
8
|
has_many :users, :through => :reserve_stat_has_users
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
paginates_per 10
|
11
|
+
attr_accessor :mode
|
12
|
+
|
13
|
+
has_many :user_reserve_stat_transitions
|
14
|
+
|
15
|
+
def state_machine
|
16
|
+
UserReserveStatStateMachine.new(self, transition_class: UserReserveStatTransition)
|
14
17
|
end
|
15
18
|
|
16
|
-
|
19
|
+
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
|
20
|
+
to: :state_machine
|
17
21
|
|
18
|
-
def calculate_count
|
22
|
+
def calculate_count!
|
19
23
|
self.started_at = Time.zone.now
|
20
24
|
User.find_each do |user|
|
21
|
-
daily_count = user.reserves.created(
|
25
|
+
daily_count = user.reserves.created(start_date.beginning_of_day, end_date.tomorrow.beginning_of_day).size
|
22
26
|
if daily_count > 0
|
23
27
|
self.users << user
|
24
|
-
sql = ['UPDATE reserve_stat_has_users SET reserves_count = ? WHERE user_reserve_stat_id = ? AND user_id = ?', daily_count,
|
25
|
-
|
28
|
+
sql = ['UPDATE reserve_stat_has_users SET reserves_count = ? WHERE user_reserve_stat_id = ? AND user_id = ?', daily_count, id, user.id]
|
29
|
+
UserReserveStat.connection.execute(
|
26
30
|
self.class.send(:sanitize_sql_array, sql)
|
27
31
|
)
|
28
32
|
end
|
29
33
|
end
|
30
34
|
self.completed_at = Time.zone.now
|
35
|
+
transition_to!(:completed)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def self.transition_class
|
40
|
+
UserReserveStatTransition
|
31
41
|
end
|
32
42
|
end
|
33
43
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class UserReserveStatStateMachine
|
2
|
+
include Statesman::Machine
|
3
|
+
state :pending, initial: true
|
4
|
+
state :started
|
5
|
+
state :completed
|
6
|
+
|
7
|
+
transition from: :pending, to: :started
|
8
|
+
transition from: :started, to: :completed
|
9
|
+
|
10
|
+
after_transition(to: :started) do |user_reserve_stat|
|
11
|
+
user_reserve_stat.update_column(:started_at, Time.zone.now)
|
12
|
+
user_reserve_stat.calculate_count!
|
13
|
+
end
|
14
|
+
|
15
|
+
after_transition(to: :completed) do |user_reserve_stat|
|
16
|
+
user_reserve_stat.update_column(:completed_at, Time.zone.now)
|
17
|
+
end
|
18
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.editing', :model => t('activerecord.models.carrier_type_has_checkout_type')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<%= render 'form' %>
|
5
5
|
</div>
|
6
6
|
</div>
|
7
7
|
|
8
|
-
<div id="submenu" class="ui-corner-all">
|
8
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
9
9
|
<ul>
|
10
10
|
<li><%= link_to t('page.show'), @carrier_type_has_checkout_type -%></li>
|
11
11
|
<li><%= link_to t('page.back'), carrier_type_has_checkout_types_path -%></li>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.carrier_type_has_checkout_type')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
@@ -16,8 +16,13 @@
|
|
16
16
|
<td><%= link_to carrier_type_has_checkout_type.checkout_type.display_name.localize, carrier_type_has_checkout_type.checkout_type -%></td>
|
17
17
|
<td><%= carrier_type_has_checkout_type.note -%></td>
|
18
18
|
<td>
|
19
|
-
<%= link_to t('page.
|
20
|
-
|
19
|
+
<%= link_to t('page.show'), carrier_type_has_checkout_type -%>
|
20
|
+
<%- if can? :update, carrier_type_has_checkout_type -%>
|
21
|
+
<%= link_to t('page.edit'), edit_carrier_type_has_checkout_type_path(carrier_type_has_checkout_type) -%>
|
22
|
+
<% end %>
|
23
|
+
<%- if can? :delete, carrier_type_has_checkout_type -%>
|
24
|
+
<%= link_to t('page.destroy'), carrier_type_has_checkout_type, :data => {:confirm => t('page.are_you_sure')}, :method => :delete -%>
|
25
|
+
<% end %>
|
21
26
|
</td>
|
22
27
|
</tr>
|
23
28
|
<%- end -%>
|
@@ -26,8 +31,10 @@
|
|
26
31
|
</div>
|
27
32
|
</div>
|
28
33
|
|
29
|
-
<div id="submenu" class="ui-corner-all">
|
34
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
30
35
|
<ul>
|
31
|
-
|
36
|
+
<%- if can? :create, CarrierTypeHasCheckoutType -%>
|
37
|
+
<li><%= link_to t('page.new', :model => t('activerecord.models.carrier_type_has_checkout_type')), new_carrier_type_has_checkout_type_path -%></li>
|
38
|
+
<% end %>
|
32
39
|
</ul>
|
33
40
|
</div>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.new', :model => t('activerecord.models.carrier_type_has_checkout_type')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<%= render 'form' %>
|
5
5
|
</div>
|
6
6
|
</div>
|
7
7
|
|
8
|
-
<div id="submenu" class="ui-corner-all">
|
8
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
9
9
|
<ul>
|
10
10
|
<li><%= link_to t('page.back'), carrier_type_has_checkout_types_path -%></li>
|
11
11
|
</ul>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.showing', :model => t('activerecord.models.carrier_type_has_checkout_type')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<p id="notice"><%= notice %></p>
|
@@ -21,9 +21,11 @@
|
|
21
21
|
</div>
|
22
22
|
</div>
|
23
23
|
|
24
|
-
<div id="submenu" class="ui-corner-all">
|
24
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
25
25
|
<ul>
|
26
|
-
|
26
|
+
<% if can?(:update, @carrier_type_has_checkout_type) %>
|
27
|
+
<li><%= link_to t('page.edit'), edit_carrier_type_has_checkout_type_path(@carrier_type_has_checkout_type) -%></li>
|
28
|
+
<% end %>
|
27
29
|
<li><%= back_to_index(flash[:page_info]) -%></li>
|
28
30
|
</ul>
|
29
31
|
</div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.checked_item')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<%= render 'checked_item' %>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
</div>
|
7
7
|
</div>
|
8
8
|
|
9
|
-
<div id="submenu" class="ui-corner-all">
|
9
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
10
10
|
<ul>
|
11
11
|
<li><%= link_to t('activerecord.models.checkin'), new_checkin_path -%></li>
|
12
12
|
</ul>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.new', :model => t('activerecord.models.checked_item')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
</div>
|
11
11
|
</div>
|
12
12
|
|
13
|
-
<div id="submenu" class="ui-corner-all">
|
13
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
14
14
|
<ul>
|
15
15
|
<li><%= link_to @basket.user.username, @basket.user -%></li>
|
16
16
|
</ul>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.showing', :model => t('activerecord.models.checked_item')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<p id="notice"><%= notice %></p>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
</div>
|
17
17
|
</div>
|
18
18
|
|
19
|
-
<div id="submenu" class="ui-corner-all">
|
19
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
20
20
|
<ul>
|
21
21
|
<li><%= link_to t('page.edit'), edit_checked_item_path(@checked_item) -%></li>
|
22
22
|
<li><%= link_to t('page.back'), basket_checked_items_path(@checked_item.basket) -%></li>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.editing', :model => t('activerecord.models.checkin')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<%= render 'form' %>
|
5
5
|
</div>
|
6
6
|
</div>
|
7
7
|
|
8
|
-
<div id="submenu" class="ui-corner-all">
|
8
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
9
9
|
<ul>
|
10
10
|
<li><%= link_to t('page.show'), @checkin -%></li>
|
11
11
|
<li><%= link_to t('page.back'), checkins_path -%></li>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.checkin')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<%= render 'checkin' %>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
</div>
|
7
7
|
</div>
|
8
8
|
|
9
|
-
<div id="submenu" class="ui-corner-all">
|
9
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
10
10
|
<ul>
|
11
11
|
<li><%= link_to t('page.new', :model => t('activerecord.models.checkin')), new_checkin_path -%></li>
|
12
12
|
<li><%= link_to t('activerecord.models.checkout'), new_basket_path -%></li>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.new', :model => t('activerecord.models.checkin')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<div id="checkin_list">
|
@@ -8,7 +8,7 @@
|
|
8
8
|
</div>
|
9
9
|
</div>
|
10
10
|
|
11
|
-
<div id="submenu" class="ui-corner-all">
|
11
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
12
12
|
<ul>
|
13
13
|
<li><%= link_to t('page.new', :model => t('activerecord.models.checkout')), new_basket_path -%></li>
|
14
14
|
<li><%= link_to t('page.listing', :model => t('activerecord.models.checkin')), checkins_path -%></li>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.showing', :model => t('activerecord.models.checkin')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<p id="notice"><%= notice %></p>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
</div>
|
17
17
|
</div>
|
18
18
|
|
19
|
-
<div id="submenu" class="ui-corner-all">
|
19
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
20
20
|
<ul>
|
21
21
|
<li><%= link_to t('page.edit'), edit_checkin_path(@checkin) -%></li>
|
22
22
|
<li><%= back_to_index(flash[:page_info]) -%></li>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.editing', :model => t('activerecord.models.checkout_stat_has_manifestation')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
<%= render 'form' %>
|
5
5
|
</div>
|
6
6
|
</div>
|
7
7
|
|
8
|
-
<div id="submenu" class="ui-corner-all">
|
8
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
9
9
|
<ul>
|
10
10
|
<li><%= link_to t('page.show'), @checkout_stat_has_manifestation -%></li>
|
11
11
|
<li><%= link_to t('page.back'), checkout_stat_has_manifestations_path -%></li>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div id="content_detail" class="ui-corner-all">
|
1
|
+
<div id="content_detail" class="ui-corner-all ui-widget-content">
|
2
2
|
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.checkout_stat_has_manifestation')) -%></h1>
|
3
3
|
<div id="content_list">
|
4
4
|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
</div>
|
27
27
|
</div>
|
28
28
|
|
29
|
-
<div id="submenu" class="ui-corner-all">
|
29
|
+
<div id="submenu" class="ui-corner-all ui-widget-content">
|
30
30
|
<ul>
|
31
31
|
<li><%= link_to t('page.new', :model => t('activerecord.models.checkout_stat_has_manifestation')), new_checkout_stat_has_manifestation_path -%></li>
|
32
32
|
</ul>
|