acts_as_footprintable 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0836653de448c2d10bb14e4e2d3bd6f0dc584ce3'
4
- data.tar.gz: f8a02be5d569784ff93fe363774e1e3de4fd8900
3
+ metadata.gz: 23d90af2f93fa15288f683b8376f4c4761918d5e
4
+ data.tar.gz: 5aab8f4d0f88e7e94031ff766b675d809a5db676
5
5
  SHA512:
6
- metadata.gz: a3b349f2dafb4fb541669e2944c9737c774ca75ac380cd578ddab47db8fb489d3b2209a228a334ec655d5dab3453191e7dbf9cbf9db85975d1d58568fe61ba6d
7
- data.tar.gz: e61673ab9a1e77f4881ee3dbe6719319eba203b3d4d5e7a8fe77767a7702eb1ff8b22b4c3fd8af430fa89062c4b159a66c16cf933bc997442d9bb874a69f9e35
6
+ metadata.gz: 0e4017dc629bd48cce469b8ed3d1d104e2300e76a53f9e64e4b1a74bde6cf1c4c2e99756ae52c5dfe6a692b4cb08c1f93d0635ff9a2b9ede5250deb731193720
7
+ data.tar.gz: '08b29b1c8e2b4424016c544eb27e41878f3b773f36316d9fefb7756cd6027f0ea5c3d8c7c750c805001f0e7aa52aeb3e2bdda6bce8db4f58c41ba1e78394e0db'
data/README.md CHANGED
@@ -16,7 +16,7 @@ The main goals of this gem are:
16
16
  Add this line to your application's Gemfile:
17
17
 
18
18
  ```ruby
19
- gem 'acts_as_footprintable', '~> 0.1.0'
19
+ gem 'acts_as_footprintable', '~> 0.4.0'
20
20
  ```
21
21
 
22
22
  And then execute:
@@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'pg'
25
25
  spec.add_development_dependency 'timecop'
26
26
  spec.add_development_dependency 'database_cleaner', "~> 1.0.1"
27
+ spec.add_development_dependency 'pry'
27
28
  #spec.add_development_dependency 'combustion', '~> 0.5.1'
28
29
  end
@@ -40,14 +40,7 @@ module ActsAsFootprintable
40
40
  def recent_footprint_ids(target, limit=nil)
41
41
  recent_footprints = target.group("#{table_name}.footprintable_id, #{table_name}.footprintable_type").
42
42
  select("#{table_name}.footprintable_id, #{table_name}.footprintable_type, MAX(#{table_name}.created_at) AS created_at")
43
- recent_footprints_conditions = recent_footprints.map{ |recent_footprint| recent_footprint.attributes.select{ |_, v| !v.nil?} }
44
- return [] if recent_footprints_conditions.first.nil?
45
-
46
- columns = recent_footprints_conditions.first.keys.map{|column| "#{table_name}.#{column}" }.join(',')
47
- values = recent_footprints_conditions.map { |row|
48
- "(#{row.values.map{|value| ActiveRecord::Base::sanitize(value)}.join(',')})"
49
- }.join(',')
50
- records = footprints.where("(#{columns}) IN (#{values})")
43
+ records = footprints.where("(#{table_name}.footprintable_id, #{table_name}.footprintable_type, #{table_name}.created_at) IN (#{recent_footprints.to_sql})")
51
44
  records = records.order("footprints.created_at desc")
52
45
  records = records.limit(limit) unless limit.nil?
53
46
  records.pluck(:id)
@@ -1,4 +1,4 @@
1
1
  # coding: utf-8
2
2
  module ActsAsFootprintable
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.0"
4
4
  end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'bundler/setup'
4
4
  require 'combustion'
5
5
  require 'database_cleaner'
6
6
  require 'timecop'
7
+ require 'pry'
7
8
 
8
9
  Combustion.initialize! :active_record
9
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_footprintable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyoaki Oko
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.0.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Rails gem to allowing records to leave footprints
98
112
  email: chariderpato@gmail.com
99
113
  executables: []