diff --git a/CHANGELOG.md b/CHANGELOG.md index df064c3fa5..168343a95a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - [#4654](https://github.com/apache/trafficcontrol/pull/4654) *Traffic Ops, Traffic Portal* Switched Delivery Service active state to a three-value system, adding a state that will be used to prevent cache servers from deploying DS configuration. ### Fixed +- [#7231](https://github.com/apache/trafficcontrol/pull/7231) *Traffic Ops, Traffic Portal* Fixed `sharedUserNames` display while retrieving CDN locks. - [#7216](https://github.com/apache/trafficcontrol/pull/7216) *Traffic Portal* Fixed sort for Server's Capabilities Table - [#4428](https://github.com/apache/trafficcontrol/issues/4428) *Traffic Ops* Fixed Internal Server Error with POST to `profileparameters` when POST body is empty - [#7179](https://github.com/apache/trafficcontrol/issues/7179) *Traffic Portal* Fixed search filter for Delivery Service Table diff --git a/traffic_ops/traffic_ops_golang/cdn_lock/cdn_lock.go b/traffic_ops/traffic_ops_golang/cdn_lock/cdn_lock.go index a2d3220299..3e58b2ba9d 100644 --- a/traffic_ops/traffic_ops_golang/cdn_lock/cdn_lock.go +++ b/traffic_ops/traffic_ops_golang/cdn_lock/cdn_lock.go @@ -36,8 +36,7 @@ import ( "github.com/lib/pq" ) -const readQuery = `SELECT username, cdn, message, soft, (select array_agg(u.username) AS shared_usernames from cdn_lock_user u join cdn_lock c on c.username = u.owner and c.cdn = u.cdn), last_updated FROM cdn_lock` - +const readQuery = `SELECT c.username, c.cdn, c.message, c.soft, c.last_updated, ARRAY_REMOVE(ARRAY_AGG(DISTINCT(u.username)), null) AS shared_usernames FROM cdn_lock_user u FULL JOIN cdn_lock c ON c.username = u.owner AND c.cdn = u.cdn` const insertQueryWithoutSharedUserNames = `INSERT INTO cdn_lock (username, cdn, message, soft) VALUES ($1, $2, $3, $4) RETURNING username, cdn, message, soft, last_updated` const insertQueryWithSharedUserNames = `WITH first_insert AS ( @@ -77,8 +76,8 @@ func Read(w http.ResponseWriter, r *http.Request) { defer inf.Close() cols := map[string]dbhelpers.WhereColumnInfo{ - "cdn": {Column: "cdn_lock.cdn", Checker: nil}, - "username": {Column: "cdn_lock.username", Checker: nil}, + "cdn": {Column: "c.cdn", Checker: nil}, + "username": {Column: "c.username", Checker: nil}, } where, orderBy, pagination, queryValues, errs := dbhelpers.BuildWhereAndOrderByAndPagination(inf.Params, cols) @@ -90,7 +89,7 @@ func Read(w http.ResponseWriter, r *http.Request) { } cdnLock := []tc.CDNLock{} - query := readQuery + where + orderBy + pagination + query := readQuery + where + orderBy + pagination + " GROUP BY c.cdn" rows, err := inf.Tx.NamedQuery(query, queryValues) if err != nil { api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, errors.New("querying cdn locks: "+err.Error())) @@ -100,7 +99,7 @@ func Read(w http.ResponseWriter, r *http.Request) { for rows.Next() { var cLock tc.CDNLock - if err = rows.Scan(&cLock.UserName, &cLock.CDN, &cLock.Message, &cLock.Soft, pq.Array(&cLock.SharedUserNames), &cLock.LastUpdated); err != nil { + if err = rows.Scan(&cLock.UserName, &cLock.CDN, &cLock.Message, &cLock.Soft, &cLock.LastUpdated, pq.Array(&cLock.SharedUserNames)); err != nil { api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, errors.New("scanning cdn locks: "+err.Error())) return } diff --git a/traffic_portal/app/src/common/modules/locks/locks.tpl.html b/traffic_portal/app/src/common/modules/locks/locks.tpl.html index 8a1341f457..0917c392f3 100644 --- a/traffic_portal/app/src/common/modules/locks/locks.tpl.html +++ b/traffic_portal/app/src/common/modules/locks/locks.tpl.html @@ -18,6 +18,6 @@
-
+