Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zizdlp committed Aug 13, 2024
1 parent 6dd8c44 commit b96ace9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 9 additions & 2 deletions zbook_backend/gapi/admin_get_daily_visitors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package gapi

import (
"context"

"math/rand"

"net/netip"
"sort"

Expand Down Expand Up @@ -71,13 +74,17 @@ func ConvertVisitor(server *Server, visitors map[string]int, lang string) []*rpc
city = record.CityNameEn.String
}
}
// 在这里添加随机扰动
latWithNoise := record.Latitude.Float64 + (rand.Float64()*2 - 1)
longWithNoise := record.Longitude.Float64 + (rand.Float64()*2 - 1)

ret_reports = append(ret_reports,
&rpcs.Visitor{
Ip: ipStr,
City: city,
Count: int32(count),
Lat: record.Latitude.Float64,
Long: record.Longitude.Float64,
Lat: latWithNoise,
Long: longWithNoise,
},
)
}
Expand Down
5 changes: 2 additions & 3 deletions zbook_frontend/src/components/charts/EarthChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function EarthChart({
}) {
markers = markers || [];
markers = [
{ ip: "66.249.66.165", lat: 37.751, long: -97.822, count: 13 },
{ ip: "66.249.66.165", lat: 37.751, long: -97.822, count: 13 },
{ ip: "66.249.66.165", lat: 37.751, long: -98.822, count: 13 },
{ ip: "66.249.66.165", lat: 38.751, long: -97.822, count: 13 },
];
const svgRef = useRef<SVGSVGElement>(null);
console.log("markers:", markers);
Expand Down Expand Up @@ -174,7 +174,6 @@ export default function EarthChart({
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<svg
ref={svgRef}
Expand Down

0 comments on commit b96ace9

Please sign in to comment.