Add Sales tab with map and crosstalk table; weekly cron at 11:45pm Sunday
All checks were successful
Deploy stAndrews / deploy (push) Successful in 4s

This commit is contained in:
2026-03-09 17:17:53 -04:00
parent 26d8c7b05c
commit 77a6721a51
2 changed files with 133 additions and 0 deletions

72
app.R
View File

@@ -17,6 +17,13 @@ listings <- readRDS("./data/listings.rds") |>
ppsf_fmt = scales::dollar(price_per_sqft)
)
shared_listings <- SharedData$new(listings, key = ~address)
sales <- readRDS("./data/sales.rds") |>
arrange(desc(listed_date)) |>
mutate(
price_fmt = scales::dollar(price),
ppsf_fmt = scales::dollar(price_per_sqft)
)
shared_sales <- SharedData$new(sales, key = ~address)
last_sale_date <- format(attr(owners, "last_sale_date"), "%Y-%m-%d")
sbdvn <- sf::st_read("./data/plats/plats.shp")
beaches <- readRDS("./data/beaches.rds")
@@ -93,6 +100,11 @@ ui <- f7Page(
title = "Listings",
icon = f7Icon("tag_fill")
),
f7PanelItem(
tabName = "Sales",
title = "Sales",
icon = f7Icon("dollarsign_circle_fill")
),
f7PanelItem(
tabName = "Resources",
title = "Resources",
@@ -249,6 +261,22 @@ ui <- f7Page(
DTOutput("listings_table")
)
),
#### sales ----
f7Tab(
title = "Sales",
tabName = "Sales",
icon = f7Icon("dollarsign_circle_fill"),
f7Card(
title = "Map:",
divider = TRUE,
leafletOutput("sales_map")
),
f7Card(
title = "Recent Sales:",
divider = TRUE,
DTOutput("sales_table")
)
),
#### services ----
f7Tab(
title = "Resources",
@@ -504,6 +532,50 @@ server <- function(input, output) {
)
})
# sales map ----
output$sales_map <- renderLeaflet({
leaflet(shared_sales) |>
addProviderTiles("CartoDB.Voyager") |>
addPolygons(
data = sbdvn,
color = "red",
weight = 2,
opacity = 0.5,
fillOpacity = 0.2,
label = ~sub_name
) |>
addMarkers(
lat = ~latitude,
lng = ~longitude,
popup = ~paste0(
"<b>", address, "</b><br>",
"Sale Date: ", listed_date, "<br>",
"Price: ", price_fmt, "<br>",
"Sq Ft: ", sqft, "<br>",
"$/Sq Ft: ", ppsf_fmt
)
) |>
setView(lng = -82.362253, lat = 27.076199, zoom = 16)
})
# sales table ----
output$sales_table <- renderDT(server = FALSE, {
datatable(
shared_sales,
colnames = c("Date", "Address", "Sq Ft", "Price (raw)", "$/Sq Ft (raw)",
"Lat", "Lng", "Price", "$/Sq Ft"),
rownames = FALSE,
options = list(
pageLength = 10,
searching = FALSE,
dom = 't',
columnDefs = list(
list(visible = FALSE, targets = c(3, 4, 5, 6))
)
)
)
})
# beach map ----
output$beach_map <- renderLeaflet({
leaflet() %>%