From 337151b39d16b3459db5954c732f4ae6d5b14739 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Sun, 6 Nov 2022 17:17:46 -0800 Subject: [PATCH] updated articles route to order by pubdate and updated swagger (#29) --- database/query.sql.go | 1 + database/schema/query.sql | 6 ++++-- routes/discordwebhooks.go | 20 ++++++++++++++++++++ routes/server.go | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/database/query.sql.go b/database/query.sql.go index d950e7d..6d63884 100644 --- a/database/query.sql.go +++ b/database/query.sql.go @@ -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 { diff --git a/database/schema/query.sql b/database/schema/query.sql index 50c13e3..4825167 100644 --- a/database/schema/query.sql +++ b/database/schema/query.sql @@ -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 diff --git a/routes/discordwebhooks.go b/routes/discordwebhooks.go index 0168c9e..0fd438c 100644 --- a/routes/discordwebhooks.go +++ b/routes/discordwebhooks.go @@ -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) + } +} diff --git a/routes/server.go b/routes/server.go index b9b3455..6121dd6 100644 --- a/routes/server.go +++ b/routes/server.go @@ -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 */