mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-02 02:48:05 +00:00
show audit events in reverse order
This commit is contained in:
@@ -87,7 +87,7 @@ func (dbobj dbcon) getAuditEvents(userTOKEN string, offset int32, limit int32) (
|
||||
return []byte("[]"), 0, err
|
||||
}
|
||||
var results []bson.M
|
||||
records, err := dbobj.store.GetList(storage.TblName.Audit, "record", userTOKEN, offset, limit)
|
||||
records, err := dbobj.store.GetList(storage.TblName.Audit, "record", userTOKEN, offset, limit, "when")
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ func (dbobj dbcon) withdrawConsentRecord(userTOKEN string, brief string, mode st
|
||||
// link consent to user?
|
||||
|
||||
func (dbobj dbcon) listConsentRecords(userTOKEN string) ([]byte, int, error) {
|
||||
records, err := dbobj.store.GetList(storage.TblName.Consent, "token", userTOKEN, 0, 0)
|
||||
records, err := dbobj.store.GetList(storage.TblName.Consent, "token", userTOKEN, 0, 0, "")
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func (dbobj dbcon) filterConsentRecords(brief string, offset int32, limit int32)
|
||||
if count == 0 {
|
||||
return []byte("[]"), 0, err
|
||||
}
|
||||
records, err := dbobj.store.GetList(storage.TblName.Consent, "brief", brief, offset, limit)
|
||||
records, err := dbobj.store.GetList(storage.TblName.Consent, "brief", brief, offset, limit, "")
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func (dbobj dbcon) getRequests(status string, offset int32, limit int32) ([]byte
|
||||
return nil, 0, err
|
||||
}
|
||||
var results []bson.M
|
||||
records, err := dbobj.store.GetList(storage.TblName.Requests, "status", status, offset, limit)
|
||||
records, err := dbobj.store.GetList(storage.TblName.Requests, "status", status, offset, limit, "when")
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
@@ -91,7 +91,7 @@ func (dbobj dbcon) getUserRequests(userTOKEN string, offset int32, limit int32)
|
||||
return nil, 0, err
|
||||
}
|
||||
var results []bson.M
|
||||
records, err := dbobj.store.GetList(storage.TblName.Requests, "token", userTOKEN, offset, limit)
|
||||
records, err := dbobj.store.GetList(storage.TblName.Requests, "token", userTOKEN, offset, limit, "")
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (dbobj dbcon) getUserSessionsByToken(userTOKEN string, offset int32, limit
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
records, err := dbobj.store.GetList(storage.TblName.Sessions, "token", userTOKEN, offset, limit)
|
||||
records, err := dbobj.store.GetList(storage.TblName.Sessions, "token", userTOKEN, offset, limit, "")
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
@@ -729,13 +729,16 @@ func (dbobj DBStorage) GetUniqueList(t Tbl, keyName string) ([]bson.M, error) {
|
||||
}
|
||||
|
||||
// GetList is used to return list of rows. It can be used to return values using pager.
|
||||
func (dbobj DBStorage) GetList(t Tbl, keyName string, keyValue string, start int32, limit int32) ([]bson.M, error) {
|
||||
func (dbobj DBStorage) GetList(t Tbl, keyName string, keyValue string, start int32, limit int32, orderField string) ([]bson.M, error) {
|
||||
table := getTable(t)
|
||||
if limit > 100 {
|
||||
limit = 100
|
||||
}
|
||||
|
||||
q := "select * from " + table + " WHERE " + escapeName(keyName) + "=$1"
|
||||
if len(orderField) > 0 {
|
||||
q = q + " ORDER BY " + escapeName(orderField) + " DESC"
|
||||
}
|
||||
if start > 0 {
|
||||
q = q + " LIMIT " + strconv.FormatInt(int64(limit), 10) +
|
||||
" OFFSET " + strconv.FormatInt(int64(start), 10)
|
||||
|
||||
@@ -76,13 +76,13 @@ func (e mainEnv) userNew(w http.ResponseWriter, r *http.Request, ps httprouter.P
|
||||
}
|
||||
if len(parsedData.emailIdx) > 0 && len(parsedData.phoneIdx) > 0 {
|
||||
// delete duplicate consent records for user
|
||||
records, _ := e.db.store.GetList(storage.TblName.Consent, "who", parsedData.emailIdx, 0, 0)
|
||||
records, _ := e.db.store.GetList(storage.TblName.Consent, "who", parsedData.emailIdx, 0, 0, "")
|
||||
var briefCodes []string
|
||||
for _, val := range records {
|
||||
//fmt.Printf("adding brief code: %s\n", val["brief"].(string))
|
||||
briefCodes = append(briefCodes, val["brief"].(string))
|
||||
}
|
||||
records, _ = e.db.store.GetList(storage.TblName.Consent, "who", parsedData.phoneIdx, 0, 0)
|
||||
records, _ = e.db.store.GetList(storage.TblName.Consent, "who", parsedData.phoneIdx, 0, 0, "")
|
||||
for _, val := range records {
|
||||
//fmt.Printf("XXX checking brief code for duplicates: %s\n", val["brief"].(string))
|
||||
if contains(briefCodes, val["brief"].(string)) == true {
|
||||
|
||||
Reference in New Issue
Block a user