genki-dm-is-taggable 0.1.6 → 0.1.7

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.
@@ -22,11 +22,13 @@ module DataMapper
22
22
 
23
23
  module TaggingClassMethods
24
24
  def total(options = {})
25
- property = DataMapper::Property.new(Tagging, :"count(*)", Integer)
25
+ property = DataMapper::Property.new(Tagging, :"count(*)",
26
+ Integer, :auto_validation => false)
26
27
  order = options[:order] || :desc
27
28
  dir = DataMapper::Query::Direction.new(property, order)
28
29
  tag_id_to_count = Tagging.aggregate(:all.count,
29
30
  options.merge(:fields => [:tag_id], :order => [dir]))
31
+ return [] if tag_id_to_count.empty?
30
32
  tag_ids, counts = tag_id_to_count.transpose
31
33
  Tag.all(:id => tag_ids).zip counts
32
34
  end
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Is
3
3
  module Taggable
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  DEPENDENCY_VERSION = ">= 0.9.6"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genki-dm-is-taggable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Qian, Maxime Guilbot