Skip to content

Commit

Permalink
Merge pull request #856 from traPtitech/main
Browse files Browse the repository at this point in the history
MultipleChoiceとCheckboxの回答のソートに対応
  • Loading branch information
MotoyaAsahina authored Apr 7, 2022
2 parents 774b7bb + c603d0c commit 5e9863e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 30 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
path: ~/go/pkg/mod
Expand All @@ -34,7 +34,7 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
path: ~/go/pkg/mod
Expand All @@ -49,7 +49,7 @@ jobs:
${{ runner.os }}-go-build-${{ github.ref }}-
${{ runner.os }}-go-build-
- run: go build -o anke-to
- uses: actions/upload-artifact@v2.3.1
- uses: actions/upload-artifact@v3
with:
name: anke-to
path: anke-to
Expand All @@ -69,7 +69,7 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
path: ~/go/pkg/mod
Expand All @@ -89,7 +89,7 @@ jobs:
with:
file: ./coverage.txt
yml: ./codecov.yml
- uses: actions/upload-artifact@v2.3.1
- uses: actions/upload-artifact@v3
with:
name: coverage.txt
path: coverage.txt
Expand All @@ -100,9 +100,9 @@ jobs:
- uses: actions/setup-go@v1
with:
go-version: 1.17
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2.0.3
uses: reviewdog/action-golangci-lint@v2.1
with:
reporter: github-pr-check
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -111,7 +111,7 @@ jobs:
name: Spectral
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Spectral checks
uses: stoplightio/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Build Docker Image (master)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
Expand Down
24 changes: 12 additions & 12 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ require (
github.com/labstack/echo/v4 v4.6.3
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/mod v0.5.0 // indirect
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
Expand All @@ -25,7 +25,7 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-playground/validator/v10 v10.10.0
github.com/go-playground/validator/v10 v10.10.1
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/labstack/gommon v0.3.1 // indirect
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-playground/validator/v10 v10.10.1 h1:uA0+amWMiglNZKZ9FJRKUAe9U3RX91eVn1JYXMWt7ig=
github.com/go-playground/validator/v10 v10.10.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand Down Expand Up @@ -335,10 +335,10 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 h1:kETrAMYZq6WVGPa8IIixL0CaEcIUNi+1WX7grUoi3y8=
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -412,8 +412,9 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210913180222-943fd674d43e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf h1:R150MpwJIv1MpS0N/pc+NhTM8ajzvlmxlY5OYsrevXQ=
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down
23 changes: 23 additions & 0 deletions model/respondents_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math"
"sort"
"strconv"
"strings"
"time"

"gopkg.in/guregu/null.v4"
Expand Down Expand Up @@ -451,6 +452,28 @@ func sortRespondentDetail(sortNum int, questionNum int, respondentDetails []Resp
}
return numi < numj
}
if bodyI.QuestionType == "MultipleChoice" {
choiceI := ""
if len(bodyI.OptionResponse) > 0 {
choiceI = bodyI.OptionResponse[0]
}
choiceJ := ""
if len(bodyJ.OptionResponse) > 0 {
choiceJ = bodyJ.OptionResponse[0]
}
if sortNum < 0 {
return choiceI > choiceJ
}
return choiceI < choiceJ
}
if bodyI.QuestionType == "Checkbox" {
selectionsI := strings.Join(bodyI.OptionResponse, ", ")
selectionsJ := strings.Join(bodyJ.OptionResponse, ", ")
if sortNum < 0 {
return selectionsI > selectionsJ
}
return selectionsI < selectionsJ
}
if sortNum < 0 {
return bodyI.Body.String > bodyJ.Body.String
}
Expand Down

0 comments on commit 5e9863e

Please sign in to comment.