refactor: Use user_id as key for pm_recipient_count.

We now key people.pm_recipient_count by user_id, which makes
one less dictionary that we'll need to update when we support
email updates.
This commit is contained in:
Steve Howell
2017-01-31 12:02:15 -08:00
committed by Tim Abbott
parent 08bc69f8af
commit d01493bc42
4 changed files with 32 additions and 14 deletions

View File

@@ -60,8 +60,21 @@ global.people.add({
assert_typeahead_equals("test no@o", false);
assert_typeahead_equals("test :-P", false);
var all_items = [{ special_item_text: 'all (Notify everyone)', email: 'all', pm_recipient_count: Infinity, full_name: 'all' },
{ special_item_text: 'everyone (Notify everyone)', email: 'everyone', full_name: 'everyone' }];
var all_items = [
{
special_item_text: 'all (Notify everyone)',
email: 'all',
pm_recipient_count: Infinity,
full_name: 'all',
},
{
special_item_text: 'everyone (Notify everyone)',
email: 'everyone',
pm_recipient_count: Infinity,
full_name: 'everyone',
},
];
var people_with_all = global.people.get_realm_persons().concat(all_items);
assert_typeahead_equals("test @o", people_with_all);

View File

@@ -135,11 +135,11 @@ initialize();
initialize();
(function test_recipient_counts() {
var email = 'anybody@example.com';
assert.equal(people.get_recipient_count({email: email}), 0);
people.incr_recipient_count(email);
people.incr_recipient_count(email);
assert.equal(people.get_recipient_count({email: email}), 2);
var user_id = 99;
assert.equal(people.get_recipient_count({id: user_id}), 0);
people.incr_recipient_count(user_id);
people.incr_recipient_count(user_id);
assert.equal(people.get_recipient_count({user_id: user_id}), 2);
assert.equal(people.get_recipient_count({pm_recipient_count: 5}), 5);
}());