-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a end user caches table. Used to store a full text index on all
the end user fields.
- Loading branch information
Doug Youch
committed
May 24, 2010
1 parent
b65b131
commit 3b8e6eb
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
class EndUserCache < DomainModel | ||
belongs_to :end_user | ||
validates_presence_of :end_user_id | ||
|
||
def before_save | ||
self.data = self.get_end_user_data.delete_if { |v| v.blank? }.join(' ') | ||
end | ||
|
||
def get_end_user_data | ||
data = [ | ||
self.end_user.email, | ||
self.end_user.name, | ||
self.end_user.user_class.name, | ||
self.end_user.source, | ||
self.end_user.registered? ? 'registered' : nil | ||
] | ||
end | ||
|
||
def self.reindex | ||
EndUser.find_in_batches do |users| | ||
users.each { |user| user.save } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters