Do not run an SQL query to get info about no repos

Closes #1649
This commit is contained in:
Sandro Santilli 2016-07-06 15:02:36 +02:00
parent 2d7c7bd860
commit bf65ac03d9
2 changed files with 12 additions and 3 deletions

View file

@ -24,6 +24,7 @@ func (db *datastore) GetRepoListOf(listof []*model.RepoLite) ([]*model.Repo, err
repos []*model.Repo
args []interface{}
stmt string
err error
)
switch meddler.Default {
case meddler.PostgreSQL:
@ -31,7 +32,9 @@ func (db *datastore) GetRepoListOf(listof []*model.RepoLite) ([]*model.Repo, err
default:
stmt, args = toList(listof)
}
err := meddler.QueryAll(db, &repos, fmt.Sprintf(repoListOfQuery, stmt), args...)
if len(args) > 0 {
err = meddler.QueryAll(db, &repos, fmt.Sprintf(repoListOfQuery, stmt), args...)
}
return repos, err
}

View file

@ -30,6 +30,7 @@ func (db *datastore) GetUserFeed(listof []*model.RepoLite) ([]*model.Feed, error
feed []*model.Feed
args []interface{}
stmt string
err error
)
switch meddler.Default {
case meddler.PostgreSQL:
@ -37,7 +38,9 @@ func (db *datastore) GetUserFeed(listof []*model.RepoLite) ([]*model.Feed, error
default:
stmt, args = toList(listof)
}
err := meddler.QueryAll(db, &feed, fmt.Sprintf(userFeedQuery, stmt), args...)
if len(args) > 0 {
err = meddler.QueryAll(db, &feed, fmt.Sprintf(userFeedQuery, stmt), args...)
}
return feed, err
}
@ -46,6 +49,7 @@ func (db *datastore) GetUserFeedLatest(listof []*model.RepoLite) ([]*model.Feed,
feed []*model.Feed
args []interface{}
stmt string
err error
)
switch meddler.Default {
case meddler.PostgreSQL:
@ -53,7 +57,9 @@ func (db *datastore) GetUserFeedLatest(listof []*model.RepoLite) ([]*model.Feed,
default:
stmt, args = toList(listof)
}
err := meddler.QueryAll(db, &feed, fmt.Sprintf(userFeedLatest, stmt), args...)
if len(args) > 0 {
err = meddler.QueryAll(db, &feed, fmt.Sprintf(userFeedLatest, stmt), args...)
}
return feed, err
}