added .julia format, tidy up
[?]
AEj8dahVWy718uSSFPe9VSRJ5qX5G8pC2zvFzJJ8yzBd
Mar 17, 2024, 12:32 AM
Q22Y36T4TRTOAYVINNLCVV6NIR3WGW6IHY7QHUTX6PITRCPLZZQQCDependencies
- [2]
WWD7AK5Vnew data 2024-02-12 - [3]
W7QD6CHHnew data for 2024-01-01 - [4]
K4V5O6JXupdated for 2023-12-04 - [5]
BVGC7DNNupdate for 25/12/23 MBM - [6]
QZTNIJSVupdated 2023-12-18 - [7]
IYLVG2FIfirst commit - [8]
2WLFHMV7New data 8/1/24 - [9]
WPCMAQQ2new data 22/1/24 - [10]
44VMPIMAcatch up commit including survey - [11]
3EZS3IU6changed metrics_plot() so it includes total sales, simplified plot
Change contents
- replacement in survey/where.png at line 1[3.21]
- replacement in survey/what.png at line 1[3.26023]
- replacement in survey/most_used_size.png at line 1[3.589706]
- replacement in survey/most_used_make.png at line 1[3.616759]
- replacement in survey/most_important.png at line 1[3.650035]
- replacement in survey/ingest_to_db.txt at line 39
p1 = df |> @vlplot(:bar, height=800, width=800,x={:how_often, axis={title="How often do you use a pack?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("how_often.png", x)p1 = df |> @vlplot(:bar, height=700, width=700, config={axis={labelFontSize=22, titleFontSize=26},scale={fontSize=22}}, x={:how_often, axis={title="How often do you use a pack?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("how_often.png", x) - replacement in survey/ingest_to_db.txt at line 42
p2 = df |> @vlplot(:bar, height=800, width=800,x={:where, axis={title="Where do you use your pack most?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("where.png", x)p2 = df |> @vlplot(:bar, height=700, width=700, config={axis={labelFontSize=22, titleFontSize=26},scale={fontSize=22}}, x={:where, axis={title="Where do you use your pack most?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("where.png", x) - replacement in survey/ingest_to_db.txt at line 45
p3 = df |> @vlplot(:bar, height=800, width=800,x={:what, axis={title="What kind of load do you carry?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("what.png", x)p3 = df |> @vlplot(:bar, height=700, width=700, config={axis={labelFontSize=22, titleFontSize=26},scale={fontSize=22}}, x={:what, axis={title="What kind of load do you carry?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("what.png", x) - replacement in survey/ingest_to_db.txt at line 72
p4 = @vlplot(:bar, height=800, width=800,x={make, axis={title="What is your all time most used pack?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("most_used_make.png", x)p4 = @vlplot(:bar, height=700, width=700, config={axis={labelFontSize=22, titleFontSize=26},scale={fontSize=22}}, x={make, axis={title="What is your all time most used pack?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("most_used_make.png", x) - replacement in survey/ingest_to_db.txt at line 75
p5 = @vlplot(:bar, height=800, width=800,x={size, axis={title="Size of most used pack?"}, sort="-y", bin={maxbins=6}}, y={"count()", axis={title="Count"}}) |> x -> save("most_used_size.png", x)p5 = @vlplot(:bar, height=700, width=700, config={axis={labelFontSize=22, titleFontSize=26},scale={fontSize=22}} , x={size, axis={title="Size of most used pack?"}, sort="-y", bin={maxbins=6}}, y={"count()", axis={title="Count"}}) |> x -> save("most_used_size.png", x) - replacement in survey/ingest_to_db.txt at line 88
l=levels(x) |> sort! #check categories and simplifyl=levels(most_important) |> sort! #check categories and simplify - replacement in survey/ingest_to_db.txt at line 90
p6 = @vlplot(:bar, height=800, width=800,x={most_important, axis={title="What is most important in a pack?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("most_important.png", x)[3.719465]p6 = @vlplot(:bar, height=700, width=700, config={axis={labelFontSize=22, titleFontSize=26},scale={fontSize=22}}, x={most_important, axis={title="What is most important in a pack?"}, sort="-y"}, y={"count()", axis={title="Count"}}) |> x -> save("most_important.png", x) - replacement in survey/how_often.png at line 1[3.719705]
- 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 9
metrics(date::String, invoices::Int) - edit in src/FiordlandPacks.jl at line 11
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 17
@show airtable_sales_for_period(date)#@show airtable_sales_for_period(date) - edit in src/FiordlandPacks.jl at line 22
"""metrics_plot() - edit in src/FiordlandPacks.jl at line 25
Takes an up to date FiordlandPacks.csv and produces some metrics.""" - replacement in src/FiordlandPacks.jl at line 34[3.938]→[3.4:289](∅→∅),[3.289]→[3.87159395:87159452](∅→∅),[3.87159452]→[3.336:480](∅→∅),[3.336]→[3.336:480](∅→∅)
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))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 67
df2 |>@vlplot(:line,x = :Week,y = :Number,color = :Metric,title = "Metrics Plot",width = 400,height = 400) |> - replacement in src/FiordlandPacks.jl at line 68
save("/Users/david/julia/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png")save("/Users/david/julia/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png",) - replacement in src/FiordlandPacks.jl at line 72
save("/media/david/SSD1/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png")endsave("/media/david/SSD1/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png")end(@vlplot(:line,x = :Week,y = :Number,color = :Metric,title = "Metrics Plot",width = 400,height = 400)(df2),) - replacement in src/FiordlandPacks.jl at line 101
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 116
Returns a unicode plot of unique site visits, compared to 1 year ago.Returns a unicode plot and a png of unique site visits, compared to 1 year ago. - replacement in src/FiordlandPacks.jl at line 125
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)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]) - replacement in src/FiordlandPacks.jl at line 132
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 144
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 145
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 149
save("/media/david/SSD1/FiordlandPacks/images_and_tables/visits_fiordland_packs.png")endsave("/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",),),),) - replacement in src/FiordlandPacks.jl at line 189
function get_page_rank(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFrame# gets page rank for previous 7 daysfunction get_page_rank(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFrame - edit in src/FiordlandPacks.jl at line 200
"""build_page_rank_table(date::String) - replacement in src/FiordlandPacks.jl at line 201
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"""# Takes a date in string form yy-mm-dd.# Returns a pretty table of top 10 pages for 7, 30, 365 days. - replacement in src/FiordlandPacks.jl at line 217
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 223
e = replace(event, "+" => " ") |> x -> titlecase(x)isempty(df) ? (return (Event=e, Number=0)) : (return (Event=e, Number=first(df.visitors)))e = (x -> titlecase(x))(replace(event, "+" => " "))if isempty(df)(return (Event=e, Number=0))else(return (Event=e, Number=first(df.visitors)))end - replacement in src/FiordlandPacks.jl at line 232
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 238
e = replace(event, "_" => " ") |> x -> titlecase(x)isempty(df) ? (return (Event=e, Number=0)) : (return (Event=e, Number=first(df.visitors)))e = (x -> titlecase(x))(replace(event, "_" => " "))if isempty(df)(return (Event=e, Number=0))else(return (Event=e, Number=first(df.visitors)))end - replacement in src/FiordlandPacks.jl at line 254
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 269
#= - edit in src/FiordlandPacks.jl at line 283
- edit in src/FiordlandPacks.jl at line 329
#= - edit in src/FiordlandPacks.jl at line 386
- replacement in images_and_tables/visits_fiordland_packs.png at line 1[3.361487]
- replacement in images_and_tables/metrics_fiordland_packs.png at line 1[3.394888]
- replacement in images_and_tables/FiordlandPacks.csv at line 26
2024-02-12,1,15,0,16,0,1,22.91[2.80731]2024-02-12,1,15,0,16,0,1,22.912024-02-19,2,14,0,16,0,1,23.192024-02-26,1,14,1,16,1,1,21.332024-03-04,0,10,1,11,1,1,19.622024-03-11,3,15,1,19,0,4,22.64 - edit in Project.toml at line 8
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" - edit in Project.toml at line 15
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"