pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
695 stars 164 forks source link

inconsistent message counts #463

Open xunam opened 12 years ago

xunam commented 12 years ago

When opening a search buffer, the status bar indicates the number of messages matching the query and the buffer displays the summaries of threads containing such messages. When retagging messages, this message count is not updated consistently. The typical case is when removing the 'inbox' tag from a thread in the initial view: the message count is decremented by the total number of messages in the thread, not the number of messages that matched the query.

pazz commented 12 years ago

yes. this is line 165 in commands/search.py i believe. instead of get_total_messages we should use dbmanager.count_messages (http://alot.readthedocs.org/en/latest/api/database.html#alot.db.DBManager.count_messages) using something like

'id:%s' and (%s)' % (thread.get_id(), currentquerystring)
pazz commented 12 years ago

check out this patch, if its ok for you i'll push it to testing..

xunam commented 12 years ago

For the use case I was describing, it seems to work fine.

Pushing the experiment further, I still get inconsistent counts in the following scenario (which I admit is rather artificial...), assuming we are on the view for tag inbox:

pazz commented 12 years ago

you're right: i totally forgot about incrementing the result count. this refresh function we use as callback after flushing needs to update this as well.

pazz commented 12 years ago

this should do it..

xunam commented 12 years ago

Not quite. Here is an experiment:

Looks like some -= should be a +=, and a display refresh is missing.

pazz commented 12 years ago

next try

pazz commented 12 years ago

i take this one is ok then? will push this to testing

pazz commented 12 years ago

pushed to master

varac commented 6 years ago

I have a similar problem. One particular search doesn't show any messages (empty buffer), but the message count shows incorrectly 58 messages. searching with notmuch for the same search terms shows 0 messages, but usign --exclude=false shows 58 messages as well.

So it seems the message count wrongly include messages tagged with one of the exclude_tags, while the search result doesn't (correctly).

pazz commented 6 years ago

this sounds like a bug. A quick inspection of the search buffer code suggests that excluded tags should also be excluded when counting results for the statusline.

varac commented 6 years ago

Is there an example notmuch database you know of that I could use to reproduce issues and report bugs without the need of anonymising ? That would really help debugging this issue.

pazz commented 6 years ago

yes it would. We don't have this yet. But there is a test corpus in the notmuch test suite..