new data and fixed formatting
[?]
AEj8dahVWy718uSSFPe9VSRJ5qX5G8pC2zvFzJJ8yzBd
Mar 17, 2024, 9:38 PM
ITZRYLYS5H5XV3R2OZOCER2AEQ2QWG7BWRKGDQ5LOKARCJ2GQYAQCDependencies
- [2]
Q22Y36T4added .julia format, tidy up - [3]
IYLVG2FIfirst commit - [4]
K4V5O6JXupdated for 2023-12-04 - [5]
EBCFJS2Ftrying to fix formatting
Change contents
- replacement in src/FiordlandPacks.jl at line 5
using Airtable,CSV, DataFrames, Dates, HTTP, Indicators, JSON3, PrettyTables, UnicodePlots, VegaLiteusing Airtable, CSV, DataFrames, Dates, HTTP, Indicators, JSON3, PrettyTables, UnicodePlots, VegaLite - edit in src/FiordlandPacks.jl at line 8
metrics(date::String, invoices::Int) - edit in src/FiordlandPacks.jl at line 9
Takes a date string and number of invoices and returns a bunch of metrics for the 7 previous days (not including the date given). - replacement in src/FiordlandPacks.jl at line 14
#@show airtable_sales_for_period(date)@show airtable_sales_for_period(date) - edit in src/FiordlandPacks.jl at line 19
"""metrics_plot() - replacement in src/FiordlandPacks.jl at line 20
Takes an up to date FiordlandPacks.csv and produces some metrics."""function metrics_plot()if Sys.isapple()file = "/Users/david/julia/FiordlandPacks/images_and_tables/FiordlandPacks.csv"elsefile = "/media/david/SSD1/FiordlandPacks/images_and_tables/FiordlandPacks.csv"enddf = DataFrame(CSV.File(file))transform!(df, [:Shopify_Sales, :Invoice_Sales] => (a, b) -> a .+ b)select!(df, :Week, :Contact_Submit, :Pack_Builder_Clicks, :Checkouts_Created, :Customer_Actions,:Shopify_Sales, :Invoice_Sales, :Shopify_Sales_Invoice_Sales_function => "Sales", :Google_Spend)table = pretty_table(last(df, 12); title="Metrics",header=["Week", "Contact", "Builder", "Checkout", "ACTIONS", "Shopify", "Invoice", "Sales", "Google"],display_size=(30, 300)) - edit in src/FiordlandPacks.jl at line 34
df2 = Base.stack(df, [:Customer_Actions, :Sales, :Google_Spend])transform!(df2, :Week => ByRow(x -> Dates.format(x, "yyyy-mm-dd")))rename!(df2, :variable => "Metric", :value => "Number")df2 |>@vlplot(:line,x = :Week,y = :Number,color = :Metric,title = "Metrics Plot",width = 400,height = 400) |>if Sys.isapple()save("/Users/david/julia/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png")elsesave("/media/david/SSD1/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png")endreturn tableend - replacement in src/FiordlandPacks.jl at line 65
function get_traffic(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFramefunction get_traffic(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFrame - replacement in src/FiordlandPacks.jl at line 78
Returns a unicode plot and a png of unique site visits, compared to 1 year ago.Returns a unicode plot of unique site visits, compared to 1 year ago. - replacement in src/FiordlandPacks.jl at line 87
c = (x -> (x -> (x -> round.(x, digits=1))(last(x, days)))(Indicators.sma(x; n=7)))(get_traffic(current, days)[!, 2])p = (x -> (x -> (x -> round.(x, digits=1))(last(x, days)))(Indicators.sma(x; n=7)))(get_traffic(last_year, days)[!, 2])c = get_traffic(current, days)[!, 2] |> x -> Indicators.sma(x, n=7) |> x -> last(x, days) |> x -> round.(x, digits=1)p = get_traffic(last_year, days)[!, 2] |> x -> Indicators.sma(x, n=7) |> x -> last(x, days) |> x -> round.(x, digits=1) - replacement in src/FiordlandPacks.jl at line 90
plt = lineplot(collect((-days):-1),[c p];color=[:blue :yellow],title="Unique Visitors: 7 day moving average",name=["Last $days Days", "Last Year"],xlabel="Day",ylabel="Visitors",canvas=DotCanvas,border=:ascii,)plt = lineplot(collect(-days:-1), [c p], color=[:blue :yellow], title="Unique Visitors: 7 day moving average", name=["Last $days Days", "Last Year"], xlabel="Day", ylabel="Visitors", canvas=DotCanvas, border=:ascii) - edit in src/FiordlandPacks.jl at line 92
vcat(DataFrame("Days" => collect(-days:-1), "Visits" => c, "Period" => "Last $days Days"), DataFrame("Days" => collect(-days:-1), "Visits" => p, "Period" => "Previous Year")) |>@vlplot(:line,x = :Days,y = :Visits,color = :Period,title = "Unique Visitors: 7 Day Moving Average",width = 400,height = 400) |> - replacement in src/FiordlandPacks.jl at line 103
save("/Users/david/julia/FiordlandPacks/images_and_tables/visits_fiordland_packs.png")save("/Users/david/julia/FiordlandPacks/images_and_tables/visits_fiordland_packs.png") - replacement in src/FiordlandPacks.jl at line 105
save("/media/david/SSD1/FiordlandPacks/images_and_tables/visits_fiordland_packs.png")end(@vlplot(:line,x = :Days,y = :Visits,color = :Period,title = "Unique Visitors: 7 Day Moving Average",width = 400,height = 400)(vcat(DataFrame("Days" => collect((-days):-1),"Visits" => c,"Period" => "Last $days Days",),DataFrame("Days" => collect((-days):-1),"Visits" => p,"Period" => "Previous Year",),),),)save("/media/david/SSD1/FiordlandPacks/images_and_tables/visits_fiordland_packs.png")end - replacement in src/FiordlandPacks.jl at line 120
# gets page rank for previous 7 daysfunction get_page_rank(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFramefunction get_page_rank(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFrame - replacement in src/FiordlandPacks.jl at line 129
# Takes a date in string form yy-mm-dd.# Returns a pretty table of top 10 pages for 7, 30, 365 days."""build_page_rank_table(date::String)Takes a date in string form yy-mm-dd.Returns a pretty table of top 10 pages for 7, 30, 365 days.Make sure repl window is wide enough""" - replacement in src/FiordlandPacks.jl at line 150
function get_custom_events(end_date::Dates.Date, event::String, days::Int=7, SITE_ID::String="fiordlandpacks.nz")::@NamedTuple{Event::String, Number::Int64}function get_custom_events(end_date::Dates.Date, event::String, days::Int=7, SITE_ID::String="fiordlandpacks.nz")::@NamedTuple{Event::String, Number::Int64} - replacement in src/FiordlandPacks.jl at line 154
e = (x -> titlecase(x))(replace(event, "+" => " "))if isempty(df)(return (Event=e, Number=0))else(return (Event=e, Number=first(df.visitors)))ende = replace(event, "+" => " ") |> x -> titlecase(x)isempty(df) ? (return (Event=e, Number=0)) : (return (Event=e, Number=first(df.visitors))) - replacement in src/FiordlandPacks.jl at line 159
function get_pageview_events(end_date::Dates.Date, event::String, days::Int=7, SITE_ID::String="fiordlandpacks.nz")::@NamedTuple{Event::String, Number::Int64}function get_pageview_events(end_date::Dates.Date, event::String, days::Int=7, SITE_ID::String="fiordlandpacks.nz")::@NamedTuple{Event::String, Number::Int64} - replacement in src/FiordlandPacks.jl at line 163
e = (x -> titlecase(x))(replace(event, "_" => " "))if isempty(df)(return (Event=e, Number=0))else(return (Event=e, Number=first(df.visitors)))ende = replace(event, "_" => " ") |> x -> titlecase(x)isempty(df) ? (return (Event=e, Number=0)) : (return (Event=e, Number=first(df.visitors))) - replacement in src/FiordlandPacks.jl at line 175
return pretty_table(df; title="North Star Metric", header=["Event", "Number"], body_hlines=[3])return pretty_table(df; title="North Star Metric", header=["Event", "Number"], body_hlines=[3]) - edit in src/FiordlandPacks.jl at line 188
#= - edit in src/FiordlandPacks.jl at line 201
- edit in src/FiordlandPacks.jl at line 203
- edit in src/FiordlandPacks.jl at line 249
#= - edit in src/FiordlandPacks.jl at line 307