From 6aebcfdbbdc9a94ca200dfed6277254de3b3840b Mon Sep 17 00:00:00 2001 From: Srijeet Chatterjee Date: Mon, 5 Dec 2022 00:40:57 -0700 Subject: [PATCH 1/2] Fix shared usernames display while retrieving CDN locks --- CHANGELOG.md | 1 + traffic_ops/traffic_ops_golang/cdn_lock/cdn_lock.go | 11 +++++------ .../app/src/common/modules/locks/locks.tpl.html | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fd3b9df92..2c8138fdaa 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 +- [#](https://github.com/apache/trafficcontrol/pull/) *Traffic Ops, Traffic Portal* Fixed `sharedUserNames` display while retrieving CDN locks. - [#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 - [#7174](https://github.com/apache/trafficcontrol/issues/7174) *Traffic Portal* Fixed topologies sort (table and Delivery Service's form) 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 @@
-
+
From 823038f0cef9a8b1ed28580d9a8931f8adf885c3 Mon Sep 17 00:00:00 2001 From: Srijeet Chatterjee Date: Mon, 5 Dec 2022 00:43:38 -0700 Subject: [PATCH 2/2] Adding changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8138fdaa..dff9dbbf74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +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 -- [#](https://github.com/apache/trafficcontrol/pull/) *Traffic Ops, Traffic Portal* Fixed `sharedUserNames` display while retrieving CDN locks. +- [#7231](https://github.com/apache/trafficcontrol/pull/7231) *Traffic Ops, Traffic Portal* Fixed `sharedUserNames` display while retrieving CDN locks. - [#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 - [#7174](https://github.com/apache/trafficcontrol/issues/7174) *Traffic Portal* Fixed topologies sort (table and Delivery Service's form)