-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1、支持指定时间段查询访问日志 2、支持指定时间段内统计点击量及独立IP数
- Loading branch information
Showing
12 changed files
with
312 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode | ||
docker/container-data/* | ||
tmp | ||
build | ||
build | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ docker/container-data/* | |
!docker/container-data/.keep | ||
tmp | ||
.DS_Store | ||
build | ||
build | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
version: '3' | ||
services: | ||
|
||
postgres: | ||
image: postgres:${PG_VERSION} | ||
container_name: ${PG_CONTAINER_NAME} | ||
hostname: postgres | ||
env_file: | ||
- ../docker/vars.env | ||
environment: | ||
- POSTGRES_USER=${PG_SUPER_USER} | ||
- POSTGRES_PASSWORD=${PG_SUPER_PWD} | ||
- TZ=PRC | ||
- PGTZ=PRC | ||
volumes: | ||
- ../structure.sql:/docker-entrypoint-initdb.d/001.sql | ||
- ../docker/container-data/postgresql:/var/lib/postgresql/data | ||
ports: | ||
- ${PG_LOCAL_PORT}:5432 | ||
healthcheck: | ||
test: [ "CMD", "psql", "-U","${PG_SUPER_USER}","-d","oh_url_shortener" ] | ||
timeout: 10s | ||
interval: 3s | ||
retries: 10 | ||
networks: | ||
- ohurlshortener | ||
|
||
redis: | ||
image: redis:${RD_VERSION} | ||
container_name: ${RD_CONTAINER_NAME} | ||
hostname: redis | ||
env_file: | ||
- ../docker/vars.env | ||
ports: | ||
- ${RD_LOCAL_PORT}:6379 | ||
healthcheck: | ||
test: [ "CMD", "redis-cli","-p","6379"] | ||
timeout: 10s | ||
interval: 3s | ||
retries: 10 | ||
networks: | ||
- ohurlshortener | ||
|
||
networks: | ||
ohurlshortener: | ||
driver: bridge | ||
name: "network_ohurlshortener" | ||
driver_opts: | ||
com.docker.network.enable_ipv6: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package storage | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestFindAccessLogsCount(t *testing.T) { | ||
init4Test(t) | ||
|
||
type args struct { | ||
url string | ||
start string | ||
end string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want int | ||
want1 int | ||
wantErr bool | ||
}{ | ||
{name: "TestCase 1", args: args{url: "", start: "", end: ""}, want: 18, want1: 7, wantErr: false}, | ||
{name: "TestCase 2", args: args{url: "gkT39tb5", start: "", end: ""}, want: 6, want1: 4, wantErr: false}, | ||
{name: "TestCase 3", args: args{url: "gkT39tb5", start: "2022-04-20", end: ""}, want: 2, want1: 1, wantErr: false}, | ||
{name: "TestCase 3", args: args{url: "gkT39tb5", start: "2022-04-07", end: "2022-04-11"}, want: 3, want1: 3, wantErr: false}, | ||
{name: "TestCase 1", args: args{url: "", start: "2022-04-01", end: ""}, want: 18, want1: 7, wantErr: false}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, got1, err := FindAccessLogsCount(tt.args.url, tt.args.start, tt.args.end) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("FindAccessLogsCount() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("FindAccessLogsCount() got = %v, want %v", got, tt.want) | ||
} | ||
if got1 != tt.want1 { | ||
t.Errorf("FindAccessLogsCount() got1 = %v, want %v", got1, tt.want1) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.