diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-02-03 08:52:18 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-02-03 08:52:18 -0500 |
commit | 75f412c4be81abfd99e2aed8c24dd15db9ae1068 (patch) | |
tree | 7e1aeb0ced8e02b8d6bed5bdce841d3f5b99f45e /store/sql_audit_store.go | |
parent | d479b08c997d3216938a3e92c3634a8b5afdb841 (diff) | |
parent | d153d661db7d4349d69824d318aa9ad571970606 (diff) | |
download | chat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.tar.gz chat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.tar.bz2 chat-75f412c4be81abfd99e2aed8c24dd15db9ae1068.zip |
Merge pull request #2049 from mattermost/plt-1856
PLT-1856 Add basic server audit tab to system console for EE
Diffstat (limited to 'store/sql_audit_store.go')
-rw-r--r-- | store/sql_audit_store.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/store/sql_audit_store.go b/store/sql_audit_store.go index 97df5f7e7..dbcb9a616 100644 --- a/store/sql_audit_store.go +++ b/store/sql_audit_store.go @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. package store @@ -72,9 +72,16 @@ func (s SqlAuditStore) Get(user_id string, limit int) StoreChannel { return } + query := "SELECT * FROM Audits" + + if len(user_id) != 0 { + query += " WHERE UserId = :user_id" + } + + query += " ORDER BY CreateAt DESC LIMIT :limit" + var audits model.Audits - if _, err := s.GetReplica().Select(&audits, "SELECT * FROM Audits WHERE UserId = :user_id ORDER BY CreateAt DESC LIMIT :limit", - map[string]interface{}{"user_id": user_id, "limit": limit}); err != nil { + if _, err := s.GetReplica().Select(&audits, query, map[string]interface{}{"user_id": user_id, "limit": limit}); err != nil { result.Err = model.NewLocAppError("SqlAuditStore.Get", "store.sql_audit.get.finding.app_error", nil, "user_id="+user_id) } else { result.Data = audits |