feedbin / support

83 stars 11 forks source link

Incorrect unread count on left hand side, for one feed #149

Closed kimptoc closed 11 years ago

kimptoc commented 11 years ago

The website is showing I have 41 unread on the left hand side, but when I select it, only 5 items are shown.

When I view things via Reeder, it shows a count of 5 and the 5 items - so I guess the website has the glitch.

I have closed/re-opened the tab in Chrome and also done a CTRL-SHFT-R - but no joy.

image

benubois commented 11 years ago

Hey Chris,

Looking at your unread count I'm not seeing anymore unread entries. Did you mark everything as read?

I'm in the process of switching to a new unread count system so there could definitely be bugs however I'm not sure I can track this particular case down.

kimptoc commented 11 years ago

Hi Ben,

Yes - I did - hmmm, guess that did not help...

Will keep an eye out for it again and let you know.

Cheers, Chris

molstrangler commented 11 years ago

I have two feeds with the same problem, I've refreshed my browser window but this did not fix the problem. I also logged out and in again, still the same problem.

https://feedbin.me/feeds/57177/entries

invalid article count

And feed https://feedbin.me/feeds/7015/entries

invalid article count 2

molstrangler commented 11 years ago

How that I've looked around I have two more feeds with incorrect unread counters;

https://feedbin.me/feeds/45827/entries shows 9 unread but only lists 5 articles https://feedbin.me/feeds/11162/entries shows 5 unread but only lists 3 articles

Zegnat commented 11 years ago

This afternoon is the first time I’m seeing it:

3 feeds, 4 unread items counted, 1 unread item displayed.

Selecting the ‘news’ label or any of the two feeds below it will not result in any entries loading.

benubois commented 11 years ago

Over the weekend I switched to a new method for tracking unread counts, so this would definitely be related to that.

Currently, Feedbin is using two systems to track unread items, one for the counts and one for actually selecting the items. I'd like to run both for a bit just to catch cases like this where they do not agree. Then once everything seems solid just the new system will be used.

It's possible that some items were missed when translating the data, so here's what would be most useful to find out if this is just missing import data or if items are not getting marked as read properly.

For now, mark everything as read. Then if the problem shows up again report back here. It would be great if anybody could provide any sort of reproducible steps.

Actions that trigger unread count changes are:

I'll check the system again to make sure there is nothing obvious missing, but so far for my account I have not been able to replicate this.

Zegnat commented 11 years ago

I have marked everything as read and will let you know if something comes up.

benubois commented 11 years ago

Closing for now. Please re-open if this comes up again.

Zegnat commented 11 years ago

And it is back. Zoompf is showed to have an unread item, but in reality does not.

I wasn’t even trying to reproduce. I was just starting to read my feeds this morning and when I finished with the web dev label it never reached 0. It also means I have no idea how to reproduce this… No API calls were involved, just reading through feedbin.me.

benubois commented 11 years ago

Great, this will be good to help troubleshoot. Before marking anything as read or doing anything else, can you see what happens when you click on Zoompf?

benubois commented 11 years ago

also the output of unread_entries.json and feeds/FEED_ID/entres.json for zoompf would be great.

Zegnat commented 11 years ago

Was working on it.

Clicking on Zoompf gets me nothing. It fires off a request for https://feedbin.me/feeds/2853/entries and the server returns a 304 and the following response:

var entries = '';

    feedbin.updateEntries(entries);

feedbin.localizeTime($('[data-behavior~=entries_target]'))

feedbin.applyUserTitles()

$('[data-behavior~=show_tags_form]').replaceWith('  <div class=\"sidebar-button button-tag\" data-behavior=\"show_tags_form\" >\n   <i class=\"icon-tag\" title=\"Tag\"><\/i>\n     <div data-behavior=\"tags_form_target\" class=\"hide\">\n             <form accept-charset=\"UTF-8\" action=\"/feeds/2853\" class=\"edit_feed\" data-behavior=\"tags_form\" data-remote=\"true\" id=\"edit_feed_2853\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input name=\"_method\" type=\"hidden\" value=\"patch\" /><\/div>\n    <span class=\"arrow-left\"><\/span>\n    <span class=\"arrow-left\"><\/span>\n    <div class=\"input-append\">\n      <input autocomplete=\"off\" id=\"feed_tag_list\" name=\"feed[tag_list]\" type=\"text\" value=\"web development\" />\n      <input class=\"btn btn-inverse\" name=\"commit\" type=\"submit\" value=\"Tag\">\n    <\/div>\n<\/form>  <div data-behavior=\"tag_completions\" class=\"completions\">\n  <\/div>\n\n      <\/div>\n  <\/div>\n');

$('[data-behavior~=unsubscribe]').replaceWith('     <a class=\"sidebar-button button-unsubscribe\" data-behavior=\"unsubscribe\" data-confirm=\"Are you sure you want to unsubscribe from Zoompf » Blog?\" data-feed-target=\"2853\" data-method=\"delete\" data-remote=\"true\" href=\"/subscriptions/23114\" rel=\"nofollow\" title=\"Unsubscribe\">\n       <i class=\"icon-trash\"><\/i>\n<\/a>');

$('[data-behavior~=mark_all_as_read]').replaceWith('  <form accept-charset=\"UTF-8\" action=\"/entries/mark_all_as_read\" data-behavior=\"mark_all_as_read\" data-remote=\"true\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><\/div>\n    <input id=\"type\" name=\"type\" type=\"hidden\" value=\"feed\" />\n    <input id=\"data\" name=\"data\" type=\"hidden\" value=\"2853\" />\n    <button class=\"sidebar-button button-mark-all-as-read\" data-confirm=\"Are you sure you want to mark all as read?\" title=\"Mark all as read\">\n      <i class=\"icon-check\"><\/i>\n<\/button><\/form>');

feedbin.updatePager('');

feedbin.data.viewMode = "view_unread";

feedbin.preloadImages([]);

The latest entry on Zoompf is ID 22254396. It has the following entry state associated with it (via API v1, v2 doesn’t do entry_state?):

        "entry_state": {
            "entry_id": 22254396,
            "read": true,
            "starred": false,
            "updated_at": "2013-05-24T07:14:19.928385Z",
            "starred_updated_at": "2013-05-24T07:14:19.921899Z",
            "read_updated_at": "2013-05-24T07:14:19.928385Z"
        }

This number is not included in unread_entries.json however. Oddly enough, there is a ‘null’ included. The full response dumps as gists: https://gist.github.com/Zegnat/f7b6957a121955785efe. They were too big to include here.

Let me know if you need anything else from me.

benubois commented 11 years ago

Alright I found something. Whenever a new entry is imported, a hook gets run to deliver the entry to all subscribers. It looks like there are a few cases where the entry_id for the unread entry is set to nil.

It currently uses after_save, but I'm thinking that the perhaps the entry.id is not always available in after_save? Anyway I'll switch to after_commit and see what happens.

Here's what this looks like:

after_commit :mark_as_unread, on: :create
def mark_as_unread
  user_ids = Subscription.where(feed_id: self.feed_id).pluck(:user_id)
  ActiveRecord::Base.transaction do
    user_ids.each do |user_id|
      UnreadEntry.create(user_id: user_id, feed_id: self.feed_id, entry_id: self.id, published: self.published, entry_created_at: self.created_at)
    end
  end
end

Line one used to be:

after_save :mark_as_unread, on: :create

Just in case I'll add some debug backtraces if I ever try to create an UnreadEntry with a nil entry_id to see if any other parts could be creating these.

Zegnat commented 11 years ago

I’ll ‘mark all as read’ on Zoompf then for now. And if I have another feed popping up with this problem it will be reported here. Let’s hope you got the bug now.

benubois commented 11 years ago

I think this is resolved now.