diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..9b5f7fa --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,31 @@ +name: Sonarqube + +on: + push: + branches: + - main + - 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 }} 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/index.html b/static/index.html index 42a3ab0..1767383 100644 --- a/static/index.html +++ b/static/index.html @@ -111,12 +111,16 @@

- + +
@@ -129,14 +133,12 @@

@@ -166,6 +168,31 @@

New Queue

+ + +