summaryrefslogtreecommitdiff
path: root/users/app/models
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2014-01-09 12:18:37 -0800
committerjessib <jessib@riseup.net>2014-01-09 12:18:37 -0800
commit6c478c5a1634b5da9d269c938f67d2ac4d8f03df (patch)
tree4a7667b0061da13b56a9ba13f7976ed2a137bb2a /users/app/models
parent90243155b425a540cb357f1c84b93effe798c9a1 (diff)
Some more cleanup, but still want to make sure by_user_ids_to_show_and_created_at view is right before issuing pull request.
Diffstat (limited to 'users/app/models')
-rw-r--r--users/app/models/message.rb2
-rw-r--r--users/app/models/user.rb9
2 files changed, 5 insertions, 6 deletions
diff --git a/users/app/models/message.rb b/users/app/models/message.rb
index 16a19f4..d9ccee8 100644
--- a/users/app/models/message.rb
+++ b/users/app/models/message.rb
@@ -6,6 +6,8 @@ class Message < CouchRest::Model::Base
property :user_ids_to_show, [String]
property :user_ids_have_shown, [String] # is this necessary to store?
+ timestamps!
+
design do
own_path = Pathname.new(File.dirname(__FILE__))
load_views(own_path.join('..', 'designs', 'message'))
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index 71e57f3..44237ff 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -76,12 +76,9 @@ class User < CouchRest::Model::Base
def messages(unseen = true)
#TODO for now this only shows unseen messages. Will we ever want seen ones? Is it necessary to store?
- #Message.by_user_ids_to_show.key(self.id).all # we don't want to emit all the userids associated with a message, so looping through to only emit text and id.
- messages = []
- Message.by_user_ids_to_show.key(self.id).each do |message|
- messages << [message.id, message.text]
- end
- messages
+
+ # we don't want to emit all the userids associated with a message, so only emit id and text.
+ Message.by_user_ids_to_show.key(self.id).map { |message| [message.id, message.text] }
end