feat(sources): add managed RSS feeds (#41)
This commit is contained in:
@ -149,7 +149,7 @@ func (r *Repository) ListSources() ([]Source, error) {
|
||||
func (r *Repository) GetSourceByType(sourceType string) (*Source, error) {
|
||||
s := &Source{}
|
||||
err := r.db.QueryRow(`
|
||||
SELECT id, name, type, enabled, created_at, article_limit, source_key FROM sources WHERE type=$1 AND source_key IN ('yahoo_finance','bloomberg','cnbc_business')`, sourceType,
|
||||
SELECT id, name, type, enabled, created_at, article_limit, source_key FROM sources WHERE type=$1 AND source_key IN ('yahoo_finance','bloomberg','cnbc_business','investing_com')`, sourceType,
|
||||
).Scan(&s.ID, &s.Name, &s.Type, &s.Enabled, &s.CreatedAt, &s.ArticleLimit, &s.SourceKey)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
@ -160,22 +160,7 @@ func (r *Repository) GetSourceByType(sourceType string) (*Source, error) {
|
||||
var ErrSourceNotSupported = errors.New("source_not_supported")
|
||||
|
||||
func (r *Repository) UpdateSource(id string, enabled bool, articleLimit *int) error {
|
||||
tx, err := r.db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
var key *string
|
||||
if err = tx.QueryRow(`SELECT source_key FROM sources WHERE id=$1 FOR UPDATE`, id).Scan(&key); err != nil {
|
||||
return err
|
||||
}
|
||||
if key == nil || !SupportedSourceKey(*key) {
|
||||
return ErrSourceNotSupported
|
||||
}
|
||||
if _, err = tx.Exec(`UPDATE sources SET enabled=$1,article_limit=COALESCE($2,article_limit) WHERE id=$3`, enabled, articleLimit, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
return r.UpdateSourceConfig(id, enabled, articleLimit, nil)
|
||||
}
|
||||
|
||||
// ── Scrape Credentials ─────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user