New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getmessage n1 #7
Conversation
74891db
to
5125aa3
Compare
|
|
|
|
|
|
|
app/src/isubata/app.go
Outdated
} | ||
|
||
users := []User{} | ||
sql := "SELECT name, display_name, avatar_icon FROM user WHERE id in (?)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messages := []MessageWithUser{}
err = db.Select(&messages, "select m.id, m.content, m.created_at, u.name, u.display_name, u.avatar_icon from message m inner join user u on u.id = m.user_id where m.id > ? and m.channel_id = ? order by m.id desc limit 100", lastID, chanID)
if err != nil {
return err
}
response := make([]map[string]interface{}, 0)
for i := len(messages) - 1; i >= 0; i-- {
m := messages[i]
r := make(map[string]interface{})
r["id"] = m.ID
r["user"] = User{
Name: m.UserName,
DisplayName: m.UserDisplayName,
AvatarIcon: m.UserAvatarIcon,
}
r["date"] = m.CreatedAt.Format("2006/01/02 15:04:05")
r["content"] = m.Content
response = append(response, r)
}
418a187
to
bba74f5
Compare
|
app/src/isubata/app.go
Outdated
sql := "SELECT * FROM user WHERE id in (?)" | ||
sql, params, err := sqlx.In(sql, uids) | ||
if err != nil { | ||
log.Fatal(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Fatal(...)
これ呼ぶのやめてw
app/src/isubata/app.go
Outdated
|
||
users := []User{} | ||
if len(uids) != 0 { | ||
sql := "SELECT * FROM user WHERE id in (?)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sqlはパッケージ名とコンフリクトするんで、回避しといたほうがヨシ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コード的にはよさそうっす |
#1