Browse Source

Map prototype

master
Maxime Wack 6 years ago
parent
commit
4baa93ffcd
1 changed files with 9 additions and 9 deletions
  1. +9
    -9
      geoip.R

+ 9
- 9
geoip.R View File

@@ -38,15 +38,15 @@ if (length(ips) > 0)
dbWriteTable(conn = db, name = "geoip", value = ., append = T)
}

src_sqlite("access.db") %>%
db %>%
tbl("access") %>%
collect %>%
left_join(geoip, by = c("ip" = "query")) %>%
select(-null1, -user, -zone, -size, -null2, -as, -countryCode, -org, -region, -regionName, -status.y, -timezone, -zip, -isp) %>%
mutate(timestamp = timestamp %>% str_sub(2) %>% as.POSIXct(format = "%d/%b/%Y:%H:%M:%S"),
req = req %>% str_replace("(HEAD|GET|POST) ", ""),
req = req %>% str_replace("/(.*?/).*", "\\1")) -> geoaccess
leaflet(data = geoaccess) %>%
left_join(db %>% tbl("geoip")) %>%
collect -> geoaccess
geoaccess %>%
filter(status != 404,
!agent %>% str_detect("bot")) %>%
distinct(ip, lon, lat) %>%
leaflet %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addMarkers(~lon, ~lat, clusterOptions = markerClusterOptions())

Loading…
Cancel
Save