Compare commits

..

No commits in common. "a0e4f1f9c48aa8908c49663b6fd2d6d7ee2b8a98" and "37142229eab90c2c7d1a422227bc0b9bdccf905c" have entirely different histories.

5 changed files with 2 additions and 20 deletions

1
.envrc
View File

@ -1,3 +1,2 @@
layout go
use flake
export INTAKE_DATA_DIR=tmp

View File

@ -48,10 +48,6 @@ func feed(
var items []core.Item
var err error
if source != "" {
if exists, err := core.SourceExists(db, source); !exists || err != nil {
log.Fatalf("error: no such source %s", source)
}
if showInactive {
items, err = core.GetAllItemsForSource(db, source)
} else {

View File

@ -39,13 +39,6 @@ func GetSources(db DB) ([]string, error) {
return names, nil
}
func SourceExists(db DB, source string) (bool, error) {
row := db.QueryRow("select count(*) from sources where name = ?", source)
var c int
err := row.Scan(&c)
return c > 0, err
}
func DeleteSource(db DB, name string) error {
_, err := db.Exec(`
delete from sources

View File

@ -14,16 +14,9 @@ import (
func TestCreateSource(t *testing.T) {
db := EphemeralDb(t)
if exists, err := SourceExists(db, "one"); exists || err != nil {
t.Fatal(err)
}
if err := AddSource(db, "one"); err != nil {
t.Fatal(err)
}
if exists, err := SourceExists(db, "one"); !exists || err != nil {
t.Fatal(err)
}
if err := AddSource(db, "two"); err != nil {
t.Fatal(err)
}

View File

@ -10,11 +10,12 @@ import (
func (env *Env) getSource(writer http.ResponseWriter, req *http.Request) {
source := req.PathValue("source")
if exists, err := core.SourceExists(env.db, source); !exists || err != nil {
if source == "" {
http.NotFound(writer, req)
return
}
// TODO this needs to properly error if the source doesn't exist instead of just returning []
var items []core.Item
var err error
inactive := req.URL.Query().Get("inactive") == "1"