-
-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow empty name during import and use FeedDiscovery to try to figure the name out if possible #1266
base: main
Are you sure you want to change the base?
Allow empty name during import and use FeedDiscovery to try to figure the name out if possible #1266
Conversation
6e109d3
to
84fe176
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor comments. Thanks for contributing!
feed.last_fetched = 1.day.ago if feed.new_record? | ||
feed.group_id = group.id if group | ||
feed.save | ||
end | ||
|
||
def find_feed_name(feed, parsed_feed) | ||
return unless parsed_feed[:name].nil? && feed.name.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like these will be the same being that we're querying for feed
based on the name from parsed_feed
. Could we instead do:
return unless parsed_feed[:name].nil? && feed.name.nil? | |
return if feed.name? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it, but the parsed_feed.slice(:name, :url)
in L31 is a bit misleading. If there's only one of the fields, it will only return that one:
3.4.1 :001 > parsed_feed = { name: "foo", url: "http://foo.com" }
=> {name: "foo", url: "http://foo.com"}
3.4.1 :002 > parsed_feed.slice(:name, :url)
=> {name: "foo", url: "http://foo.com"}
3.4.1 :003 > parsed_feed = { name: "foo" }
=> {name: "foo"}
3.4.1 :004 > parsed_feed.slice(:name, :url)
=> {name: "foo"}
3.4.1 :005 > parsed_feed = { url: "http://foo.com" }
=> {url: "http://foo.com"}
3.4.1 :006 > parsed_feed.slice(:name, :url)
=> {url: "http://foo.com"}
In other words, slice will not return nil fields, fields not found are just ignored.
I'll tweak the spec to make that clearer, I thought about it but forgot to do it
Co-authored-by: Robert Fletcher <[email protected]>
While testing stringer locally, I tried to import my feeds from The Old Reader. The OPML generated by The Old Reader doesn't contain the feed names, so the import failed.
I made a change to allow nils and the import went through, but then the feeds had no name and it was hard to manage the feeds.
So I replicated the logic from
Feed::Create
to try to get a proper title for the Feed.This will make the import slower in the case there's nameless entries, but the result seems to be better. I'm falling back to the url if the call to the feed failed to avoid retrying on dead feeds.