e9_tags 0.0.10 → 0.0.11

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.
@@ -2,8 +2,16 @@ module E9Tags::Rack
2
2
  class TagsJs
3
3
  def self.call(env)
4
4
  if env["PATH_INFO"] =~ /^\/js\/tags/
5
- tags = ::Tagging.joins(:tag).order('tags.name').group_by(&:context).to_json
6
- js = "window.e9=window.e9||{};window.e9.tags=#{tags};"
5
+ rel = ::Tagging
6
+ .joins(:tag)
7
+ .order('tags.name')
8
+ .select('distinct taggings.context, tags.name')
9
+
10
+ retv = ::Tagging.connection
11
+ .select_rows(rel.to_sql, 'Tags JS')
12
+ .inject({}) {|h, row| (h[row.first] ||= []) << row.last; h }
13
+
14
+ js = "window.e9=window.e9||{};window.e9.tags=#{retv.to_json};"
7
15
 
8
16
  [200, {"Content-Type" => "text/javascript", "Cache-Control" => "max-age=3600, must-revalidate"}, [js]]
9
17
  else
@@ -1,3 +1,3 @@
1
1
  module E9Tags
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: e9_tags
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.10
5
+ version: 0.0.11
6
6
  platform: ruby
7
7
  authors:
8
8
  - Travis Cox