diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 6b8c03661..8ef719241 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -15,6 +15,7 @@ class BidsController < ApplicationController @bids = @bids.like(params[:name]) if params[:name].present? @bid_count = @bids.count @bid_pages = Paginator.new @bid_count, @limit, params['page'] + @offset ||= @bid_pages.reverse_offset #@bids = @bids.offset(@offset).limit(@limit).all.reverse unless @offset == 0 diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index ab05474fe..ccfeccd68 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -7,6 +7,7 @@ class TagsController < ApplicationController include UsersHelper include BidsHelper include ActsAsTaggableOn::TagsHelper + helper :projects $selected_tags = Array.new $related_tags = Array.new @@ -21,23 +22,56 @@ class TagsController < ApplicationController @users_tags_num = User.tag_counts.size @bids_tags_num = Bid.tag_counts.size - @issues_results = get_issues_by_tag($selected_tags) - @projects_results = get_projects_by_tag($selected_tags) - @users_results = get_users_by_tag($selected_tags) - @bids_results = get_bids_by_tag($selected_tags) + # 这里为了提高系统的响应速度 把搜索结果放到case中去了 + @users_results = nil + @projects_results = nil + @issues_results = nil + @bids_results = nil + @obj_pages = nil @obj_id = params[:obj_id] @obj_flag = params[:object_flag] + @numbers = Setting.tags_show_search_results case @obj_flag when '1' then + @users_results = get_users_by_tag($selected_tags) @obj = User.find_by_id(@obj_id) + + @offset, @limit = api_offset_and_limit({:limit => @numbers}) + @project_count = @users_results.count + @obj_pages = Paginator.new @project_count, @limit, params['page'] + @offset ||= @obj_pages.offset + @users_results = @users_results.offset(@offset).limit(@limit).all when '2' then + @projects_results = get_projects_by_tag($selected_tags) @obj = Project.find_by_id(@obj_id) + + @offset, @limit = api_offset_and_limit({:limit => @numbers}) + @project_count = @projects_results.count + @obj_pages = Paginator.new @project_count, @limit, params['page'] + @offset ||= @obj_pages.offset + @projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all + when '3' then + @issues_results = get_issues_by_tag($selected_tags) @obj = Issue.find_by_id(@obj_id) + + @offset, @limit = api_offset_and_limit({:limit => @numbers}) + @project_count = @issues_results.count + @obj_pages = Paginator.new @project_count, @limit, params['page'] + @offset ||= @obj_pages.offset + @issues_results = @issues_results.offset(@offset).limit(@limit).all when '4' + @bids_results = get_bids_by_tag($selected_tags) @obj = Bid.find_by_id(@obj_id) + + @offset, @limit = api_offset_and_limit({:limit => @numbers}) + @project_count = @bids_results.count + @obj_pages = Paginator.new @project_count, @limit, params['page'] + @offset ||= @obj_pages.offset + @bids_results = @bids_results.offset(@offset).limit(@limit).all + else @obj = nil end @@ -83,4 +117,12 @@ class TagsController < ApplicationController end + def for_pagination(results) + @offset, @limit = api_offset_and_limit({:limit => 2}) + @project_count = results.count + @obj_pages = Paginator.new @project_count, @limit, params['page'] + @offset ||= @obj_pages.offset + results = results.offset(@offset).limit(@limit).order('lft').all + end + end diff --git a/app/models/user.rb b/app/models/user.rb index e27c6a782..ae672b53a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -99,7 +99,9 @@ class User < Principal acts_as_taggable scope :by_join_date, order("created_at DESC") ############################# added by liuping 关注 - acts_as_watchable + acts_as_watchable + has_one :user_extensions + ## end attr_accessor :password, :password_confirmation attr_accessor :last_before_login_on diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb index f70cddad8..47578e66f 100644 --- a/app/models/user_extensions.rb +++ b/app/models/user_extensions.rb @@ -1,4 +1,5 @@ class UserExtensions < ActiveRecord::Base + belongs_to :user attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code #this method was used to update the table user_extensions def update_user_extensions(birthday=nil,brief_introduction=nil, diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 9a75481ad..2143dee68 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -5,8 +5,6 @@

<%= l(:label_my_account)%>

- -
+ + + <%= submit_tag l(:button_save) %>
<% end %> diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 4435727fc..8f4852ef5 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -25,7 +25,7 @@ diff --git a/app/views/tags/_related_tags.html.erb b/app/views/tags/_related_tags.html.erb index 84fb06923..42b3c010f 100644 --- a/app/views/tags/_related_tags.html.erb +++ b/app/views/tags/_related_tags.html.erb @@ -1,5 +1,5 @@ <% if related_tags %> -