From 0417582530cffca05b8366bea170124cc2f91bb7 Mon Sep 17 00:00:00 2001 From: Noah Hanford Date: Wed, 4 Mar 2026 09:27:09 -0500 Subject: [PATCH 1/5] Add Sonarqube workflow for code analysis --- .github/workflows/sonarqube.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/sonarqube.yml diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..02f62cf --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,30 @@ +name: Sonarqube + +on: + push: + branches: + - dev + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Analyze + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: SonarSource/sonarqube-scan-action@v5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + # If you wish to fail your job when the Quality Gate is red, uncomment the + # following lines. This would typically be used to fail a deployment. + # We do not recommend to use this in a pull request. Prefer using pull request + # decoration instead. + # - uses: SonarSource/sonarqube-quality-gate-action@v1 + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 453c9f1f159414dbac9a870eac68b86e51abec51 Mon Sep 17 00:00:00 2001 From: Noah Hanford Date: Wed, 4 Mar 2026 09:27:41 -0500 Subject: [PATCH 2/5] Add 'main' branch to SonarQube workflow triggers --- .github/workflows/sonarqube.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 02f62cf..9b5f7fa 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -3,6 +3,7 @@ name: Sonarqube on: push: branches: + - main - dev pull_request: types: [opened, synchronize, reopened] From a8366aa1b48ffd43023ae079b0fa4f26e97da9f3 Mon Sep 17 00:00:00 2001 From: "Noah Hanford (spaced)" Date: Sat, 18 Apr 2026 10:51:34 -0400 Subject: [PATCH 3/5] reset queue api --- main.go | 1 + queue/queue.go | 31 +++++++++++++++++++++++++++++++ static/javascript/index.js | 5 ++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 13edd62..5059fe6 100644 --- a/main.go +++ b/main.go @@ -82,6 +82,7 @@ func main() { apiMux.HandleFunc("DELETE /queue/{queue}", discussion.DeleteQueue) apiMux.HandleFunc("GET /queue/{queue}/path", discussion.GetQueuePath) apiMux.HandleFunc("GET /discussion", discussion.GetDiscussion) + apiMux.HandleFunc("PUT /discussion/reset", discussion.ResetDiscussion) apiMux.HandleFunc("/joinws", ws_server.WebsocketConnect) http.Handle("/api/", http.StripPrefix("/api", auth.Handler(apiMux))) diff --git a/queue/queue.go b/queue/queue.go index 27f43e0..fd055ce 100644 --- a/queue/queue.go +++ b/queue/queue.go @@ -63,6 +63,37 @@ func SetupDiscussion(wsServer *dq_websocket.WsServer) *Discussion { return &discussion } +func (discussion *Discussion) ResetDiscussion(w http.ResponseWriter, r *http.Request) { + userInfo := auth.GetUserClaims(r) + + if !userInfo.IsEboard { + w.WriteHeader(http.StatusForbidden) + return + } + + discussion.queueCount = 0 + discussion.queueMap = make(map[int]*Queue) + + baseQueue := Queue{ + Id: discussion.queueCount, + Points: make([]QueueEntry, 0), + Clarifiers: make([]QueueEntry, 0), + Children: make([]*Queue, 0), + Topic: "Big long discussion", + pointCount: 0, + } + + discussion.queueCount++ + discussion.Queue = &baseQueue + discussion.queueMap[baseQueue.Id] = &baseQueue + + discussion.wsServer.SendWSMessage(struct { + Type string `json:"type"` + }{ + Type: "refresh", + }) +} + func (discussion *Discussion) NewQueue(w http.ResponseWriter, r *http.Request) { userInfo := auth.GetUserClaims(r) diff --git a/static/javascript/index.js b/static/javascript/index.js index f1d74f9..722f79d 100644 --- a/static/javascript/index.js +++ b/static/javascript/index.js @@ -116,7 +116,7 @@ function joinWebsocket(retryCount = 0) { const protocol = isSecure ? "wss" : "ws"; const socket = new WebSocket(`${protocol}://${window.location.host}/api/joinws`); - socket.addEventListener("message", (event) => { + socket.addEventListener("message", async (event) => { const eventData = JSON.parse(event.data); switch (eventData.type) { @@ -143,6 +143,9 @@ function joinWebsocket(retryCount = 0) { case "move-to-queue": loadQueueDom(eventData.queue); break; + case "refresh": + await rebuildQueue(); + break; } }); From becec437e1f8f40d1b2242e95b02ff95738a7fe5 Mon Sep 17 00:00:00 2001 From: "Noah Hanford (spaced)" Date: Sat, 18 Apr 2026 10:54:55 -0400 Subject: [PATCH 4/5] better buttons --- static/index.html | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/static/index.html b/static/index.html index 42a3ab0..f07253e 100644 --- a/static/index.html +++ b/static/index.html @@ -129,14 +129,12 @@

From 4d3dd4c3fc818fd31c53f64b1aec19d3adf0e0fc Mon Sep 17 00:00:00 2001 From: "Noah Hanford (spaced)" Date: Sat, 18 Apr 2026 11:34:44 -0400 Subject: [PATCH 5/5] reset api --- static/index.html | 31 ++++++++++++++++++++++++++++++- static/javascript/index.js | 11 +++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/static/index.html b/static/index.html index f07253e..1767383 100644 --- a/static/index.html +++ b/static/index.html @@ -111,12 +111,16 @@

- + +
@@ -164,6 +168,31 @@

New Queue

+ + +