updated articles route to order by pubdate and updated swagger (#29)

This commit is contained in:
James Tombleson 2022-11-06 17:17:46 -08:00 committed by GitHub
parent 63b19452e5
commit 337151b39d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 3 deletions

View File

@ -354,6 +354,7 @@ const getArticlesBySource = `-- name: GetArticlesBySource :many
select articles.id, sourceid, articles.tags, title, articles.url, pubdate, video, videoheight, videowidth, thumbnail, description, authorname, authorimage, sources.id, site, name, source, type, value, enabled, sources.url, sources.tags from articles
INNER join sources on articles.sourceid=Sources.ID
where site = $1
ORDER By pubdate desc
`
type GetArticlesBySourceRow struct {

View File

@ -11,12 +11,14 @@ Where Url = $1 LIMIT 1;
Select * From articles Limit $1;
-- name: ListArticlesByDate :many
Select * From articles ORDER BY pubdate desc Limit $1;
Select * From articles
ORDER BY pubdate desc Limit $1;
-- name: GetArticlesBySource :many
select * from articles
INNER join sources on articles.sourceid=Sources.ID
where site = $1;
WHERE site = $1
ORDER By pubdate desc;
-- name: GetArticlesBySourceId :many
Select * From articles

View File

@ -189,3 +189,23 @@ func (s *Server) deleteDiscordWebHook(w http.ResponseWriter, r *http.Request) {
log.Panic(err)
}
}
// UpdateDiscordWebHook
// @Summary Updates a valid discord webhook ID based on the body given.
// @Param id path string true "id"
// @Tags Config, Discord, Webhook
// @Router /discord/webhooks/{id} [delete]
func (s *Server) UpdateDiscordWebHook(w http.ResponseWriter, r *http.Request) {
id := chi.URLParam(r, "ID")
uuid, err := uuid.Parse(id)
if err != nil {
log.Panicln(err)
}
// Check to make sure we can find the record
_, err = s.Db.GetDiscordQueueByID(*s.ctx, uuid)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
}
}

View File

@ -65,7 +65,7 @@ func (s *Server) MountMiddleware() {
func (s *Server) MountRoutes() {
s.Router.Get("/swagger/*", httpSwagger.Handler(
httpSwagger.URL("http://localhost:8081/swagger/doc.json"), //The url pointing to API definition
httpSwagger.URL("doc.json"), //The url pointing to API definition
))
/* Root Routes */