unidom-action 1.11.1 → 1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/app/models/unidom/action/searching.rb +35 -0
- data/db/migrate/20000513000000_create_unidom_searchings.rb +40 -0
- data/lib/unidom/action/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae82632bdbe721eb5def25d0d834f6a49afe8c0d
|
4
|
+
data.tar.gz: 5ee64e10a05141906b0a211e06f83fe15b661b77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e74b76a5b54fa09d681eebb5dac6343f65480f67bb795ff86e5de4dcbf7407757dca55a966a5ac8720e567746d88c59b3f53b22cc1d817936a646e9908a236ad
|
7
|
+
data.tar.gz: 1d5798175d74e01e376c4d14ac5ef0fae461b0c5acd70b336e1ff334627ff94dababa1a61344b9c44ed30bfe2f1dfa36ac65a0ea09549fb92b8a7c5f49138a86
|
data/README.md
CHANGED
@@ -67,6 +67,15 @@ obsolescing = Unidom::Action::Obsolescing.create! obsolescer_visitor: user, obso
|
|
67
67
|
obsolescing = Unidom::Action::Obsolescing.obsolesce! obsolesced: person, obsolescer_visitor: user, obsolescer_party: person, reason: reason, obsolescence_code: 'OBSL', opened_at: Time.now
|
68
68
|
# The reason could be nil.
|
69
69
|
obsolescings = Unidom::Action::Obsolescing.obsolesced_via(user).obsolesced_by(person).obsolesced_is(person).caused_by(reason).obsolescence_coded_as('OBSL')
|
70
|
+
|
71
|
+
# Search the people
|
72
|
+
found_count = Unidom::Party::Person.where(name: 'Tim').count
|
73
|
+
shown_count = ... # the item count on the current page, it's calculated per found_count, page, & per_page
|
74
|
+
total_pages = ... # the total page count calculated per found_count, & per_page
|
75
|
+
|
76
|
+
@people = Unidom::Party::Person.where(name: 'Tim').paginate page: params[:page], per_page: params[:per_page]||Rails.configuration.pagination[:administration_v2_people][:per_page]
|
77
|
+
|
78
|
+
searching = Unidom::Action::Searching.create! searcher_visitor: user, searcher_party: person, reason_id: reason.id, resource_name: 'person', platform_name: 'administration', platform_version: '2', criteria: { name: 'Tim' }, found_count: found_count, shown_count: show_count, per_page: params[:per_page]||Rails.configuration.pagination[:administration_v2_people][:per_page], total_pages: total_pages, current_page: params[:page]
|
70
79
|
```
|
71
80
|
|
72
81
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Searching 是行为的原因。
|
2
|
+
# #activity_code 是活动代码。
|
3
|
+
|
4
|
+
class Unidom::Action::Searching < Unidom::Action::ApplicationRecord
|
5
|
+
|
6
|
+
self.table_name = 'unidom_searchings'
|
7
|
+
|
8
|
+
include Unidom::Common::Concerns::ModelExtension
|
9
|
+
|
10
|
+
validates :resource_name, presence: true, length: { maximum: self.columns_hash['resource_name'].limit }
|
11
|
+
validates :found_count, presence: true, numericality: { integer_only: true, greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
12
|
+
validates :shown_count, presence: true, numericality: { integer_only: true, greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
13
|
+
validates :per_page, presence: true, numericality: { integer_only: true, greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
14
|
+
validates :total_pages, presence: true, numericality: { integer_only: true, greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
15
|
+
validates :current_page, presence: true, numericality: { integer_only: true, greater_than_or_equal_to: 0, less_than: 1_000_000_000 }
|
16
|
+
|
17
|
+
belongs_to :searcher_visitor, polymorphic: true
|
18
|
+
belongs_to :searcher_party, polymorphic: true
|
19
|
+
belongs_to :searcher_reason, class_name: 'Unidom::Action::Reason'
|
20
|
+
|
21
|
+
scope :searched_by, ->(searcher_party) { where searcher_party: searcher_party }
|
22
|
+
scope :searched_via, ->(searcher_visitor) { where searcher_visitor: searcher_visitor }
|
23
|
+
scope :caused_by, ->(reason) { where reason_id: to_id(reason) }
|
24
|
+
|
25
|
+
scope :resource_name_is, ->(resource_name) { where resource_name: resource_name }
|
26
|
+
scope :platform_name_is, ->(platform_name) { where platform_name: platform_name }
|
27
|
+
scope :platform_version_is, ->(platform_version) { where platform_version: platform_version }
|
28
|
+
|
29
|
+
scope :found_count_is, ->(found_count) { where found_count: found_count }
|
30
|
+
scope :shown_count_is, ->(shown_count) { where shown_count: shown_count }
|
31
|
+
scope :per_page_is, ->(per_page) { where per_page: per_page }
|
32
|
+
scope :current_page_is, ->(current_page) { where current_page: current_page }
|
33
|
+
scope :total_pages_is, ->(total_pages) { where total_pages: total_pages }
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class CreateUnidomSearchings < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
|
5
|
+
create_table :unidom_searchings, id: :uuid do |t|
|
6
|
+
|
7
|
+
t.references :searcher_visitor, type: :uuid, null: true,
|
8
|
+
polymorphic: { null: true, default: nil, limit: 200 }
|
9
|
+
t.references :searcher_party, type: :uuid, null: true,
|
10
|
+
polymorphic: { null: true, default: nil, limit: 200 }
|
11
|
+
t.references :reason, type: :uuid, null: true
|
12
|
+
|
13
|
+
t.string :resource_name, null: false, default: '', limit: 200
|
14
|
+
t.string :platform_name, null: false, default: '', limit: 200
|
15
|
+
t.integer :platform_version, null: false, default: 1
|
16
|
+
|
17
|
+
t.jsonb :criteria, null: false, default: {}
|
18
|
+
t.integer :found_count, null: false, default: 0, limit: 8
|
19
|
+
t.integer :shown_count, null: false, default: 0
|
20
|
+
t.integer :per_page, null: false, default: 0
|
21
|
+
t.integer :total_pages, null: false, default: 0
|
22
|
+
t.integer :current_page, null: false, default: 1
|
23
|
+
|
24
|
+
t.column :state, 'char(1)', null: false, default: 'C'
|
25
|
+
t.datetime :opened_at, null: false, default: Time.utc(1970)
|
26
|
+
t.datetime :closed_at, null: false, default: Time.utc(3000)
|
27
|
+
t.boolean :defunct, null: false, default: false
|
28
|
+
t.jsonb :notation, null: false, default: {}
|
29
|
+
|
30
|
+
t.timestamps null: false
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
add_index :unidom_searchings, :searcher_visitor_id
|
35
|
+
add_index :unidom_searchings, :searcher_party_id
|
36
|
+
add_index :unidom_searchings, :reason_id
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.12'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- app/models/unidom/action/concerns/as_state_transitor_party.rb
|
68
68
|
- app/models/unidom/action/obsolescing.rb
|
69
69
|
- app/models/unidom/action/reason.rb
|
70
|
+
- app/models/unidom/action/searching.rb
|
70
71
|
- app/models/unidom/action/state_transition.rb
|
71
72
|
- app/types/unidom/action/action.rb
|
72
73
|
- app/types/unidom/action/obsolescence.rb
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- db/migrate/20000510000000_create_unidom_actings.rb
|
79
80
|
- db/migrate/20000511000000_create_unidom_state_transitions.rb
|
80
81
|
- db/migrate/20000512000000_create_unidom_obsolescings.rb
|
82
|
+
- db/migrate/20000513000000_create_unidom_searchings.rb
|
81
83
|
- lib/tasks/action_tasks.rake
|
82
84
|
- lib/unidom/action.rb
|
83
85
|
- lib/unidom/action/engine.rb
|