Skip to content

Commit

Permalink
不要の関数を削除した
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattuki committed May 29, 2024
1 parent 4231675 commit 23ba92f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
14 changes: 0 additions & 14 deletions database/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@ func GetMessagesByPage(page int, name string) ([]Message, error) {
}
}

func GetAllMessages() ([]Message, error) {
db := GetDBConnection()
var messages []Message
err := db.Select(_all_message_field).Order("created_on DESC").Find(&messages).Error
return messages, err
}

func GetAllMessagesByCreatorName(creatorName string) ([]Message, error) {
db := GetDBConnection()
var messages []Message
err := db.Select(_all_message_field).Where("creator_name=?", creatorName).Order("created_on DESC").Find(&messages).Error
return messages, err
}

func GetNumberOfPages() (int64, error) {
db := GetDBConnection()
var count int64
Expand Down
30 changes: 0 additions & 30 deletions handler/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,8 @@ func HandleGetMessagesByPage(c echo.Context) error {
if err != nil {
return c.String(http.StatusNotFound, "invalid path parameter")
}

name := c.QueryParam("name")

/*var messages []database.Message
var messagesToSend []database.Message
if name == "" {
messages, err = database.GetAllMessages()
} else {
messages, err = database.GetAllMessagesByCreatorName(name)
}
if err != nil {
log.Println(err)
return c.String(http.StatusInternalServerError, "failed to get messages from the database")
}
//現在のpageに対応しているメッセージを計算する
messagesSize := len(messages)
start := 10 * (page - 1)
if start > (messagesSize-1) || start < 0 {
return c.String(http.StatusNotFound, "invalid path parameter")
}
var end int
if 10*page <= messagesSize {
end = 10 * page
} else {
end = messagesSize
}
messagesToSend = messages[start:end]
return c.JSON(http.StatusOK, messagesToSend)*/

messages, err := database.GetMessagesByPage(page, name)
if err != nil {
log.Println(err)
Expand Down

0 comments on commit 23ba92f

Please sign in to comment.