mirror of
https://github.com/owncast/owncast.git
synced 2024-11-22 12:49:37 +03:00
Optimize chat history query. Helps #1890
This commit is contained in:
parent
8a343d0324
commit
2c47ddeef0
2 changed files with 2 additions and 2 deletions
|
@ -289,7 +289,7 @@ func GetChatModerationHistory() []interface{} {
|
||||||
// GetChatHistory will return all the chat messages suitable for returning as user-facing chat history.
|
// GetChatHistory will return all the chat messages suitable for returning as user-facing chat history.
|
||||||
func GetChatHistory() []interface{} {
|
func GetChatHistory() []interface{} {
|
||||||
// Get all visible messages
|
// Get all visible messages
|
||||||
query := fmt.Sprintf("SELECT messages.id,messages.user_id, messages.body, messages.title, messages.subtitle, messages.image, messages.link, messages.eventType, messages.hidden_at, messages.timestamp, users.display_name, users.display_color, users.created_at, users.disabled_at, users.previous_names, users.namechanged_at, users.authenticated_at, users.scopes, users.type FROM messages LEFT JOIN users ON messages.user_id = users.id WHERE hidden_at IS NULL AND disabled_at IS NULL ORDER BY timestamp DESC LIMIT %d", maxBacklogNumber)
|
query := fmt.Sprintf("SELECT messages.id, messages.user_id, messages.body, messages.title, messages.subtitle, messages.image, messages.link, messages.eventType, messages.hidden_at, messages.timestamp, users.display_name, users.display_color, users.created_at, users.disabled_at, users.previous_names, users.namechanged_at, users.authenticated_at, users.scopes, users.type FROM users JOIN messages ON users.id = messages.user_id WHERE hidden_at IS NULL AND disabled_at IS NULL ORDER BY timestamp DESC LIMIT %d", maxBacklogNumber)
|
||||||
m := getChat(query)
|
m := getChat(query)
|
||||||
|
|
||||||
// Invert order of messages
|
// Invert order of messages
|
||||||
|
|
|
@ -118,7 +118,7 @@ func (ds *Datastore) Setup() {
|
||||||
"key" string NOT NULL PRIMARY KEY,
|
"key" string NOT NULL PRIMARY KEY,
|
||||||
"value" BLOB,
|
"value" BLOB,
|
||||||
"timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL
|
"timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL
|
||||||
);`
|
);CREATE INDEX IF NOT EXISTS messages_timestamp_index ON messages(timestamp);`
|
||||||
|
|
||||||
stmt, err := ds.DB.Prepare(createTableSQL)
|
stmt, err := ds.DB.Prepare(createTableSQL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue