Seneca-CDOT / telescope

A tool for tracking blogs in orbit around Seneca's open source involvement
https://telescope.cdot.systems
BSD 2-Clause "Simplified" License
94 stars 188 forks source link

Create /admin/import route to allow bulk import of feeds #1058

Closed humphd closed 2 years ago

humphd commented 4 years ago

Building off of https://github.com/Seneca-CDOT/telescope/issues/294#issuecomment-618584788, let's create a new route:

POST /admin/import

This is a protected route (admins only) that allows sending feed data in a number of formats. To begin, I'd like to be able to send data in the Planet Feed List text format. Later we could include other types (OPML, etc).

When this data is posted to the server, we should do the same sort of thing that happens in POST /feeds and call Feed.create() on each of the feeds we get sent.

This is part of what we need to eliminate the need to keep the wiki feed list. Once this is working, we can do a one-time import of the old data, and then stop syncing with the wiki.

humphd commented 4 years ago

This will also need tests (obviously!).

c3ho commented 4 years ago

I'll leave this issue until tomorrow afternoon before assigning it to myself

c3ho commented 4 years ago

I have a question when working on this

Given the following text

  `################# Failing Feeds Commented Out [Start] #################

#Feed excluded due to getaddrinfo ENOTFOUND s-aleinikov.blog.ca s-aleinikov.blog.ca:80
#[http://s-aleinikov.blog.ca/feed/atom/posts/]
#name=Sergey Aleinikov

#Feed excluded due to getaddrinfo ENOTFOUND rickeyre.ca rickeyre.ca:80
#[http://rickeyre.ca/open-source-feed.xml]
#name=Rick Eyre

[http://kopay.wordpress.com/category/sbr600-win2011/feed]
name=Pirathapan Sivalingam

[http://jessefulton.wordpress.com/category/SBR600/feed/]
name=Jesse Fulton`

Do you want me to bother with trying to create a feed with first two feeds (the ones marked #)?

manekenpix commented 4 years ago

@c3ho Do you have to process the feeds? I thought you only had to add a way to import them and then wiki-feed-parser or the processor would do the rest. Also, I think the wiki-feed-parser has something to avoid comments here. Maybe you can add something there to process commented feeds (but I think it's easier to just uncomment them).

c3ho commented 4 years ago

@manekenpix Thanks. I took a look over the code and that was what I thought at first too

@humphd Are we going to be writing another file just like wiki-feed-parser or making changes to the code? If I was to create another file, a lot of the code would look similar except for the part where instead of creating a dom and getting all the text inside <pre> I'm getting all the text inside req.files

humphd commented 4 years ago

I would use what we have, refactor/rename as you see fit, and eliminate the code that uses it now (we don't need to update from the wiki over and over, we'll just read from all unflagged feeds for each repetition of the feed parser).

If you want to keep your life simple, we could make it so that we don't have to send any data to the route: you hit /admin/import/wiki and it runs exactly what we have now, and adds all those feeds.

We'd only ever run this once on staging and once on admin. Later we'll probably add backup/restore routes, so we we'll likely ditch this in the future.

humphd commented 2 years ago

I don't think we need this. I'll re-open if it becomes necessary.