[Logilogi-svn] SF.net SVN: logilogi:[1783] trunk
Status: Beta
Brought to you by:
wybow
|
From: <wy...@us...> - 2011-03-01 08:17:34
|
Revision: 1783
http://logilogi.svn.sourceforge.net/logilogi/?rev=1783&view=rev
Author: wybow
Date: 2011-03-01 08:17:28 +0000 (Tue, 01 Mar 2011)
Log Message:
-----------
Improved efficiency of homepage
Modified Paths:
--------------
trunk/app/models/used_tag.rb
trunk/db/schema.rb
Added Paths:
-----------
trunk/db/migrate/20110301070022_used_tag_cloud_visibility.rb
Modified: trunk/app/models/used_tag.rb
===================================================================
--- trunk/app/models/used_tag.rb 2011-01-04 21:33:59 UTC (rev 1782)
+++ trunk/app/models/used_tag.rb 2011-03-01 08:17:28 UTC (rev 1783)
@@ -41,21 +41,13 @@
#
def self.top_used_tags(options = {})
if options.delete(:no_special)
- if options[:limit]
- limit = options[:limit]
- options[:limit] = options[:limit] * 2
+ if !options[:conditions]
+ options[:conditions] = []
end
- toppers = UsedTag.find(:all, options.merge(
- :order => "use_count DESC")).reject {|t|
- t.tag.name? or t.tag.home_page? or t.tag.system? }
- if !options[:limit]
- limit = toppers.size
- end
- return toppers[0...limit].sort_by {|used_tag| used_tag.tag}
- else
- return UsedTag.find(:all, options.merge(
- :order => "use_count DESC")).sort_by {|used_tag| used_tag.tag}
+ options[:conditions].push('cloud_visibility = true')
end
+ return UsedTag.find(:all, options.merge(
+ :order => "use_count DESC")).sort_by {|used_tag| used_tag.tag}
end
### Parsing
@@ -98,6 +90,10 @@
#
def self.use(tag)
u_t = UsedTag.or_new_from_tag(tag)
+ # TODO make more efficient
+ if tag.name? or tag.home_page? or tag.system?
+ u_t.cloud_visibility = false
+ end
u_t.increment
u_t.save
end
Added: trunk/db/migrate/20110301070022_used_tag_cloud_visibility.rb
===================================================================
--- trunk/db/migrate/20110301070022_used_tag_cloud_visibility.rb (rev 0)
+++ trunk/db/migrate/20110301070022_used_tag_cloud_visibility.rb 2011-03-01 08:17:28 UTC (rev 1783)
@@ -0,0 +1,25 @@
+class UsedTagCloudVisibility < ActiveRecord::Migration
+ def self.up
+ add_column :used_tags, :cloud_visibility, :boolean, :default => true, :null => false
+
+ if GlobalConfig.available?
+ UsedTagCloudVisibility.update
+ end
+ end
+
+ def self.down
+ raise 'No way back'
+ end
+
+ def self.update
+ # Change language as needed
+ UsedTag.find(:all).each {|t|
+ if t.tag.name? or t.tag.home_page? or t.tag.system?
+ t.cloud_visibility = false
+ else
+ t.cloud_visibility = true
+ end
+ t.save
+ }
+ end
+end
Modified: trunk/db/schema.rb
===================================================================
--- trunk/db/schema.rb 2011-01-04 21:33:59 UTC (rev 1782)
+++ trunk/db/schema.rb 2011-03-01 08:17:28 UTC (rev 1783)
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100923165007) do
+ActiveRecord::Schema.define(:version => 20110301070022) do
create_table "acts_as_xapian_jobs", :force => true do |t|
t.string "model", :null => false
@@ -261,8 +261,9 @@
add_index "steps", ["path_id"], :name => "index_steps_on_path_id"
create_table "used_tags", :force => true do |t|
- t.string "string", :limit => 80, :null => false
- t.integer "use_count", :default => 0, :null => false
+ t.string "string", :limit => 80, :null => false
+ t.integer "use_count", :default => 0, :null => false
+ t.boolean "cloud_visibility", :default => true, :null => false
end
add_index "used_tags", ["string"], :name => "index_used_tags_on_string"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|