Compare commits

..
6 Commits
Author SHA1 Message Date
Dustin Pianalto 24aff1be72 Fix request message
CI / build (push) Has been cancelled
2021-02-22 22:19:25 -09:00
Dustin Pianalto b28beaba0c Fix request message 2021-02-22 22:18:59 -09:00
Dustin Pianalto 4f8aaff94a Fix request message 2021-02-22 22:17:18 -09:00
Dustin Pianalto a21e884bee Fix bug getting messages from db
CI / build (push) Has been cancelled
2021-02-22 22:12:07 -09:00
Dustin Pianalto faf64a8bf9 Add message to end of list with count
CI / build (push) Has been cancelled
2021-02-22 22:03:06 -09:00
Dustin Pianalto 2abe574977 Update database schema to not allow null previous_content
CI / build (push) Has been cancelled
2021-02-22 21:56:18 -09:00
4 changed files with 10 additions and 3 deletions
+4 -1
View File
@@ -9,6 +9,7 @@ import (
"github.com/dustinpianalto/disgoman" "github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/geeksbot" "github.com/dustinpianalto/geeksbot"
"github.com/dustinpianalto/geeksbot/internal/discord_utils" "github.com/dustinpianalto/geeksbot/internal/discord_utils"
"github.com/dustinpianalto/geeksbot/internal/utils"
"github.com/dustinpianalto/geeksbot/pkg/services" "github.com/dustinpianalto/geeksbot/pkg/services"
) )
@@ -234,7 +235,7 @@ func listCommandFunc(ctx disgoman.Context, args []string) {
_, _ = ctx.Send(fmt.Sprintf("```md\n"+ _, _ = ctx.Send(fmt.Sprintf("```md\n"+
"< Request ID Requested By >\n"+ "< Request ID Requested By >\n"+
"< %11s %-23s >\n"+ "< %-11d %23s >\n"+
"%s\n\n"+ "%s\n\n"+
"Comments: Not Implemented Yet\n"+ "Comments: Not Implemented Yet\n"+
"Requested At: %s\n"+ "Requested At: %s\n"+
@@ -247,4 +248,6 @@ func listCommandFunc(ctx disgoman.Context, args []string) {
channelName, channelName,
)) ))
} }
_, _ = ctx.Send(fmt.Sprintf("```There %s currently %d open %s```", utils.PluralizeString("is", len(requests)), len(requests), utils.PluralizeString("request", len(requests))))
} }
+3
View File
@@ -17,5 +17,8 @@ func PluralizeString(s string, i int) string {
if i == 1 { if i == 1 {
return s return s
} }
if s == "is" {
return "are"
}
return s + "s" return s + "s"
} }
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"log" "log"
"github.com/dustinpianalto/geeksbot" "github.com/dustinpianalto/geeksbot"
"github.com/lib/pq"
) )
type messageService struct { type messageService struct {
@@ -21,7 +22,7 @@ func (s messageService) Message(id string) (geeksbot.Message, error) {
WHERE m.id = $1` WHERE m.id = $1`
row := s.db.QueryRow(queryString, id) row := s.db.QueryRow(queryString, id)
err := row.Scan(&m.ID, &m.CreatedAt, &m.ModifiedAt, &m.Content, err := row.Scan(&m.ID, &m.CreatedAt, &m.ModifiedAt, &m.Content,
&m.PreviousContent, &channel_id, &author_id) pq.Array(&m.PreviousContent), &channel_id, &author_id)
if err != nil { if err != nil {
return geeksbot.Message{}, err return geeksbot.Message{}, err
} }
@@ -2,5 +2,5 @@ BEGIN;
ALTER TABLE messages ALTER TABLE messages
ALTER COLUMN previous_content SET NOT NULL; ALTER COLUMN previous_content SET NOT NULL;
ALTER TABLE messages ALTER TABLE messages
ALTER COLUMN prevous_content SET DEFAULT array[]::varchar[]; ALTER COLUMN previous_content SET DEFAULT array[]::varchar[];
COMMIT; COMMIT;