From 337d79b80e8a9a49cc67fdfbc943868e44097abf Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Fri, 3 Dec 2021 10:45:43 +0800 Subject: [PATCH 1/2] update version to 0.19.2 --- apidoc/apidoc.py | 8 ++++++++ apidoc/get_user_visit_count.yaml | 19 +++++++++++++++++++ apidoc/template.yaml | 2 +- docker-compose.yaml | 2 +- docker-compose.yaml.template | 2 +- initgin/init_gin_test.go | 8 ++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 apidoc/get_user_visit_count.yaml diff --git a/apidoc/apidoc.py b/apidoc/apidoc.py index 227effa1..eb24d642 100644 --- a/apidoc/apidoc.py +++ b/apidoc/apidoc.py @@ -282,6 +282,14 @@ def _get_fav(uid): return '' +@app.route(_with_app_prefix('/uservisitcount'), methods=['GET']) +def _get_user_visit_count(): + """ + swagger_from_file: apidoc/get_user_visit_count.yaml + """ + return '' + + @app.route(_with_app_prefix('/existsuser'), methods=['POST']) def _check_exists_user(): """ diff --git a/apidoc/get_user_visit_count.yaml b/apidoc/get_user_visit_count.yaml new file mode 100644 index 00000000..8c25e017 --- /dev/null +++ b/apidoc/get_user_visit_count.yaml @@ -0,0 +1,19 @@ +getUserVisitCount +--- +tags: + - user + - count +description: get user visit count (the most recent 10 mins) +parameters: + - '$ref': '#/definitions/Host' + - '$ref': '#/definitions/XForwardedFor' + - '$ref': '#/definitions/Authorization' +responses: + 200: + schema: + '$id': https://json-schema.org/draft/2019-09/output/schema + type: object + properties: + total: + type: number + description: total. diff --git a/apidoc/template.yaml b/apidoc/template.yaml index 97df61e5..cda8f716 100644 --- a/apidoc/template.yaml +++ b/apidoc/template.yaml @@ -1,5 +1,5 @@ info: - version: '0.19.1' + version: '0.19.2' title: go-pttbbs definitions: !include defs/board_summary.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml index de20ef40..8eff248a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,7 @@ version: '2' services: go-pttbbs: - image: pttofficialapps/go-pttbbs:v0.19.1 + image: pttofficialapps/go-pttbbs:v0.19.2 ports: - "127.0.0.1:3456:3456" - "127.0.0.1:8889:8888" diff --git a/docker-compose.yaml.template b/docker-compose.yaml.template index 314ba9b0..8c769c7a 100644 --- a/docker-compose.yaml.template +++ b/docker-compose.yaml.template @@ -1,7 +1,7 @@ version: '2' services: go-pttbbs: - image: pttofficialapps/go-pttbbs:v0.19.1 + image: pttofficialapps/go-pttbbs:v0.19.2 ports: - "127.0.0.1:3456:3456" - "127.0.0.1:8889:8888" diff --git a/initgin/init_gin_test.go b/initgin/init_gin_test.go index 0937445b..1a67040c 100644 --- a/initgin/init_gin_test.go +++ b/initgin/init_gin_test.go @@ -474,6 +474,14 @@ func TestInitGin(t *testing.T) { method: "GET", }, }, + { + name: "GetUserVisitCount", + args: args{ + path: fmt.Sprintf("/uservisitcount"), + jwt: jwtTest, + method: "GET", + }, + }, { name: "EditArticle", args: args{ From b73f8f1b0565690bd267ab95de016e1e79c87815 Mon Sep 17 00:00:00 2001 From: Chuan-Heng Hsiao Date: Fri, 3 Dec 2021 11:04:51 +0800 Subject: [PATCH 2/2] add wg in api.TestGetUserVisitCount --- api/get_user_visit_count_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/get_user_visit_count_test.go b/api/get_user_visit_count_test.go index 3a8716fc..ad11843c 100644 --- a/api/get_user_visit_count_test.go +++ b/api/get_user_visit_count_test.go @@ -2,6 +2,7 @@ package api import ( "reflect" + "sync" "testing" "unsafe" @@ -33,8 +34,11 @@ func TestGetUserVisitCount(t *testing.T) { false, }, } + var wg sync.WaitGroup for _, tt := range tests { + wg.Add(1) t.Run(tt.name, func(t *testing.T) { + defer wg.Done() got, err := GetUserVisitCount(testIP, nil) if (err != nil) != tt.wantErr { t.Errorf("GetUserVisitCount() error = %v, wantErr %v", err, tt.wantErr) @@ -44,5 +48,6 @@ func TestGetUserVisitCount(t *testing.T) { t.Errorf("GetUserVisitCount() got = %v, want %v", got, tt.want) } }) + wg.Wait() } }