Skip to content

Commit

Permalink
Add fields: Time, Confirmed
Browse files Browse the repository at this point in the history
  • Loading branch information
jellyterra committed Jan 9, 2025
1 parent 86ff7bf commit 8e7780a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type AccessReport struct {
UserAgent string `redis:"UserAgent" json:"user_agent"`
DeployTime string `redis:"DeployTime" json:"deploy_time"`
Target string `redis:"Target" json:"target"`
Time int `redis:"Time" json:"time"`
Confirmed int `redis:"Confirmed" json:"confirmed"`
}

func Wrap(h func(w http.ResponseWriter, r *http.Request) (int, error)) http.HandlerFunc {
Expand Down
4 changes: 4 additions & 0 deletions server/api_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func V1GetApi(e *ApiEnv) map[string]http.HandlerFunc {
userAgent = wrap.String("user_agent", "")
deployTime = wrap.StringRequired("deploy_time")
target = wrap.StringRequired("target")
time = wrap.Int("time", 0)
confirmed = wrap.Int("confirmed", 0)
)
err = wrap.Parse()
if err != nil {
Expand All @@ -42,6 +44,8 @@ func V1GetApi(e *ApiEnv) map[string]http.HandlerFunc {
UserAgent: *userAgent,
DeployTime: *deployTime,
Target: *target,
Time: *time,
Confirmed: *confirmed,
})
if err != nil {
return http.StatusInternalServerError, err
Expand Down
2 changes: 1 addition & 1 deletion server/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (db *Database) CountAll(ctx context.Context, userAgentFilter []string) erro
break
}
}
if isFiltered {
if report.Confirmed == 0 || isFiltered {
continue
}

Expand Down

0 comments on commit 8e7780a

Please sign in to comment.