app/models/user.rb in solarsearch-0.0.9 vs app/models/user.rb in solarsearch-0.0.10
- old
+ new
@@ -25,13 +25,16 @@
PASSWORD_MIN_LENGTH = 4
PASSWORD_MAX_LENGTH = 40
EMAIL_MAX_LENGTH = 50
USERNAME_RANGE = USERNAME_MIN_LENGTH..USERNAME_MAX_LENGTH
PASSWORD_RANGE = PASSWORD_MIN_LENGTH..PASSWORD_MAX_LENGTH
+
+ #configuration settings
MAX_NUMBER_OF_ARTICLES_PER_NEWSUPDATE = 10
- MAX_SIZE_OF_A_MAIL_IN_CHARACTERS = 10000
+ MAX_SIZE_OF_A_MAIL_IN_CHARACTERS = 20000
NEWSUPDATE_RECENT_NUMBER_OF_DAYS = 120
+ QUERY_AUGMENT_PARTIAL = ''
=begin
validates_uniqueness_of :username, :email
validates_confirmation_of :password
validates_length_of :username, :within => USERNAME_RANGE
@@ -93,29 +96,33 @@
search_keywords.each do |search_keyword|
article_update = recent_articles_for_search_keyword(search_keyword)
set_all_articles += article_update
end
arr_all_articles = set_all_articles.to_a
- arr_all_articles = arr_all_articles.find_all { |article| article_condition.call(article) } if article_condition
+ arr_all_articles = arr_all_articles.find_all do |article|
+ article_condition.call(article)
+ end if article_condition
arr_all_articles.sort! { |article1, article2| article2.published_at <=> article1.published_at }
arr_all_articles = arr_all_articles[0, MAX_NUMBER_OF_ARTICLES_PER_NEWSUPDATE]
arr_all_articles
end
def recent_articles_for_search_keyword(search_keyword)
searchquery = search_keyword.query
self_user = self
search = Sunspot.search(Article) do
- keywords searchquery
+ keywords "#{searchquery} #{QUERY_AUGMENT_PARTIAL}"
with(:published_at).greater_than Time.now - NEWSUPDATE_RECENT_NUMBER_OF_DAYS.day
dynamic :status do
without Article.give_user_status_symbol(self_user, ArticleStatus::STATUS_VIEWED), true
without Article.give_user_status_symbol(self_user, ArticleStatus::STATUS_SENT), true
end
order_by(:published_at, :desc)
paginate(:page => 1, :per_page => MAX_NUMBER_OF_ARTICLES_PER_NEWSUPDATE)
end
- search.results
+ #FIXME: This is for debugging purposes, trying to catch a hardly reproducably bug, which I dont understand why happens
+ STDERR << search.results.to_a.to_s
+ search.results.to_a
end
def can_be_modified_by(user)
!user.nil? and (user==self or user.has_role?(:admin))
end