ging/social_stream — Issue #139: Mismatch on the contacts count vs contacts shown on the page
Author: luca
Created: 2011-10-13 17:22:04+00:00
State: open

In the index action of the contacts controller we have this to find the contacts:

```ruby
@contacts =
Contact.sent_by(current_subject).
joins(:receiver).merge(Actor.alphabetic).
merge(Actor.letter(params[:letter])).
merge(Actor.name_search(params[:search])).
related_by_param(params[:relation]).
active
# and then ...
@contacts = @contacts.page(params[:page]).per(10)
```

that is we find the current page of all the contacts sent by the current_subject (filtered)

on the page to set the number of records found we have this:

```ruby
current_subject.contact_subjects(:direction => :sent).count
```

which calls Actor.contact_actors which by default filters only the actors having Relation::Custom or Relation::Public ties.

The method used in the controller still finds all the contacts which the subject may have refused (i.e. those with Relation::Reject) and thus they are shown on the page, moreover the difference in how the count is calculated may be a problem in the future (the two methods can diverge for good reasons).