dmohan001c commented on a change in pull request #6235:
URL: https://github.com/apache/trafficcontrol/pull/6235#discussion_r717244459



##########
File path: traffic_ops/traffic_ops_golang/logs/log.go
##########
@@ -135,11 +163,64 @@ FROM "log" as l JOIN tm_user as u ON l.tm_user = u.id`
 
 const countQuery = `SELECT count(l.tm_user) FROM log as l`
 
+func getLogV40(inf *api.APIInfo, days int) ([]tc.Log, uint64, error) {
+       var count = uint64(0)
+       var whereCount string
+
+       queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
+               "username": {Column: "u.username", Checker: nil},
+       }
+       where, _, pagination, queryValues, errs :=
+               dbhelpers.BuildWhereAndOrderByAndPagination(inf.Params, 
queryParamsToQueryCols)
+
+       if len(errs) > 0 {
+               return nil, 0, util.JoinErrs(errs)
+       }
+
+       timeInterval := fmt.Sprintf("l.last_updated > now() - INTERVAL '%v' 
DAY", days)
+       if where != "" {
+               whereCount = ", tm_user as u\n" + where + " AND l.tm_user = 
u.id"
+               where = where + " AND " + timeInterval
+       } else {
+               whereCount = where
+               where = "\nWHERE " + timeInterval
+       }
+       queryCount := countQuery + whereCount
+       rowCount, err := inf.Tx.NamedQuery(queryCount, queryValues)
+       if err != nil {
+               return nil, count, errors.New("querying log count for a given 
user: " + err.Error())
+       }
+       defer rowCount.Close()
+       for rowCount.Next() {
+               if err = rowCount.Scan(&count); err != nil {
+                       return nil, count, errors.New("scanning logs: " + 
err.Error())

Review comment:
       Fixed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to