added .julia format, tidy up

[?]
AEj8dahVWy718uSSFPe9VSRJ5qX5G8pC2zvFzJJ8yzBd
Mar 17, 2024, 12:32 AM
Q22Y36T4TRTOAYVINNLCVV6NIR3WGW6IHY7QHUTX6PITRCPLZZQQC

Dependencies

Change contents

  • replacement in survey/where.png at line 1
    [3.21][3.22:26000]()
    [3.21]
  • replacement in survey/what.png at line 1
    [3.26023][3.26024:45801]()
    [3.26023]
  • replacement in survey/most_used_size.png at line 1
    [3.589706][3.589707:616727]()
    [3.589706]
  • replacement in survey/most_used_make.png at line 1
    [3.616759][3.616760:650003]()
    [3.616759]
  • replacement in survey/most_important.png at line 1
    [3.650035][3.650036:716744]()
    [3.650035]
  • replacement in survey/ingest_to_db.txt at line 39
    [3.717945][3.717945:718134]()
    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)
    [3.717945]
    [3.718134]
    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
    [3.718135][3.718135:718320]()
    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)
    [3.718135]
    [3.718320]
    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
    [3.718321][3.718321:718503]()
    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)
    [3.718321]
    [3.718503]
    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
    [3.718842][3.718842:719033]()
    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)
    [3.718842]
    [3.719033]
    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
    [3.719034][3.719034:719228]()
    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)
    [3.719034]
    [3.719228]
    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
    [3.719412][3.719412:719464]()
    l=levels(x) |> sort! #check categories and simplify
    [3.719412]
    [3.719464]
    l=levels(most_important) |> sort! #check categories and simplify
  • replacement in survey/ingest_to_db.txt at line 90
    [3.719465][3.719465:719662]()
    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][3.719706:741889]()
    [3.719705]
  • replacement in src/FiordlandPacks.jl at line 5
    [3.230][3.230:332]()
    using Airtable, CSV, DataFrames, Dates, HTTP, Indicators, JSON3, PrettyTables, UnicodePlots, VegaLite
    [3.230]
    [3.332]
    using Airtable,
    CSV, DataFrames, Dates, HTTP, Indicators, JSON3, PrettyTables, UnicodePlots, VegaLite
  • edit in src/FiordlandPacks.jl at line 9
    [3.337]
    [3.337]
    metrics(date::String, invoices::Int)
  • edit in src/FiordlandPacks.jl at line 11
    [3.338]
    [3.338]
    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
    [3.487][3.487:529]()
    @show airtable_sales_for_period(date)
    [3.487]
    [3.529]
    #@show airtable_sales_for_period(date)
  • edit in src/FiordlandPacks.jl at line 22
    [3.670]
    [3.670]
    """
    metrics_plot()
  • edit in src/FiordlandPacks.jl at line 25
    [3.671]
    [3.671]
    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))
    [3.938]
    [3.1107]
    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
    [3.1333][3.1333:1520]()
    df2 |>
    @vlplot(
    :line,
    x = :Week,
    y = :Number,
    color = :Metric,
    title = "Metrics Plot",
    width = 400,
    height = 400
    ) |>
  • replacement in src/FiordlandPacks.jl at line 68
    [3.1541][3.93:189]()
    save("/Users/david/julia/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png")
    [3.1541]
    [3.1632]
    save(
    "/Users/david/julia/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png",
    )
  • replacement in src/FiordlandPacks.jl at line 72
    [3.1641][3.1641:1744]()
    save("/media/david/SSD1/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png")
    end
    [3.1641]
    [3.1744]
    save(
    "/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
    [3.2064][3.2064:2166]()
    function get_traffic(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFrame
    [3.2064]
    [3.2166]
    function get_traffic(
    end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz"
    )::DataFrame
  • replacement in src/FiordlandPacks.jl at line 116
    [3.2511][3.2511:2581]()
    Returns a unicode plot of unique site visits, compared to 1 year ago.
    [3.2511]
    [3.2581]
    Returns a unicode plot and a png of unique site visits, compared to 1 year ago.
  • replacement in src/FiordlandPacks.jl at line 125
    [3.2777][3.2777:3023]()
    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)
    [3.2777]
    [3.3023]
    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
    [3.3024][3.3024:3244]()
    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)
    [3.3024]
    [3.3244]
    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
    [3.3245][3.3245:3628]()
    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
    [3.3649][3.190:285]()
    save("/Users/david/julia/FiordlandPacks/images_and_tables/visits_fiordland_packs.png")
    [3.3649]
    [3.3739]
    save(
    "/Users/david/julia/FiordlandPacks/images_and_tables/visits_fiordland_packs.png"
    )
  • replacement in src/FiordlandPacks.jl at line 149
    [3.3748][3.3748:3850]()
    save("/media/david/SSD1/FiordlandPacks/images_and_tables/visits_fiordland_packs.png")
    end
    [3.3748]
    [3.3850]
    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",
    ),
    ),
    ),
    )
  • replacement in src/FiordlandPacks.jl at line 189
    [3.4100][3.4100:4204]()
    function get_page_rank(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFrame
    [3.4100]
    [3.4204]
    # gets page rank for previous 7 days
    function get_page_rank(
    end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz"
    )::DataFrame
  • edit in src/FiordlandPacks.jl at line 200
    [3.4537][3.4537:4578]()
    """
    build_page_rank_table(date::String)
  • replacement in src/FiordlandPacks.jl at line 201
    [3.4579][3.4579:4718]()
    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
    """
    [3.4579]
    [3.4718]
    # 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
    [3.5166][3.5166:5323]()
    function get_custom_events(end_date::Dates.Date, event::String, days::Int=7, SITE_ID::String="fiordlandpacks.nz")::@NamedTuple{Event::String, Number::Int64}
    [3.5166]
    [3.5323]
    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
    [3.5595][3.5595:5746]()
    e = replace(event, "+" => " ") |> x -> titlecase(x)
    isempty(df) ? (return (Event=e, Number=0)) : (return (Event=e, Number=first(df.visitors)))
    [3.5595]
    [3.5746]
    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
    [3.5778][3.5778:5937]()
    function get_pageview_events(end_date::Dates.Date, event::String, days::Int=7, SITE_ID::String="fiordlandpacks.nz")::@NamedTuple{Event::String, Number::Int64}
    [3.5778]
    [3.5937]
    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
    [3.6210][3.6210:6361]()
    e = replace(event, "_" => " ") |> x -> titlecase(x)
    isempty(df) ? (return (Event=e, Number=0)) : (return (Event=e, Number=first(df.visitors)))
    [3.6210]
    [3.6361]
    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
    [3.6746][3.6746:6846]()
    return pretty_table(df; title="North Star Metric", header=["Event", "Number"], body_hlines=[3])
    [3.6746]
    [3.6846]
    return pretty_table(
    df; title="North Star Metric", header=["Event", "Number"], body_hlines=[3]
    )
  • edit in src/FiordlandPacks.jl at line 269
    [3.7225]
    [3.7225]
    #=
  • edit in src/FiordlandPacks.jl at line 283
    [3.7715][3.7715:7717]()
  • edit in src/FiordlandPacks.jl at line 329
    [3.9693][3.9693:9696]()
    #=
  • edit in src/FiordlandPacks.jl at line 386
    [3.12208][3.12208:12210]()
  • replacement in images_and_tables/visits_fiordland_packs.png at line 1
    [3.361487][2.21:32605]()
    [3.361487]
  • replacement in images_and_tables/metrics_fiordland_packs.png at line 1
    [3.394888][2.32607:80698]()
    [3.394888]
  • replacement in images_and_tables/FiordlandPacks.csv at line 26
    [2.80731][2.80731:80761]()
    2024-02-12,1,15,0,16,0,1,22.91
    [2.80731]
    2024-02-12,1,15,0,16,0,1,22.91
    2024-02-19,2,14,0,16,0,1,23.19
    2024-02-26,1,14,1,16,1,1,21.33
    2024-03-04,0,10,1,11,1,1,19.62
    2024-03-11,3,15,1,19,0,4,22.64
  • edit in Project.toml at line 8
    [3.649216]
    [3.649216]
    Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
  • edit in Project.toml at line 15
    [3.649505]
    [3.649505]
    JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"