new data and fixed formatting

[?]
AEj8dahVWy718uSSFPe9VSRJ5qX5G8pC2zvFzJJ8yzBd
Mar 17, 2024, 9:38 PM
ITZRYLYS5H5XV3R2OZOCER2AEQ2QWG7BWRKGDQ5LOKARCJ2GQYAQC

Dependencies

Change contents

  • replacement in src/FiordlandPacks.jl at line 5
    [3.230][2.352925:353031]()
    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 8
    [3.337][2.353032:353073]()
    metrics(date::String, invoices::Int)
  • edit in src/FiordlandPacks.jl at line 9
    [3.338][2.353074:353204]()
    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
    [3.487][2.353205:353248]()
    #@show airtable_sales_for_period(date)
    [3.487]
    [3.529]
    @show airtable_sales_for_period(date)
  • edit in src/FiordlandPacks.jl at line 19
    [3.670][2.353249:353271]()
    """
    metrics_plot()
  • replacement in src/FiordlandPacks.jl at line 20
    [3.671][2.353272:353342]()
    Takes an up to date FiordlandPacks.csv and produces some metrics.
    """
    [3.671]
    [3.1107]
    function metrics_plot()
    if Sys.isapple()
    file = "/Users/david/julia/FiordlandPacks/images_and_tables/FiordlandPacks.csv"
    else
    file = "/media/david/SSD1/FiordlandPacks/images_and_tables/FiordlandPacks.csv"
    end
    df = 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
    [3.1108]
    [3.1765]
    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")
    else
    save("/media/david/SSD1/FiordlandPacks/images_and_tables/metrics_fiordland_packs.png")
    end
    return table
    end
  • replacement in src/FiordlandPacks.jl at line 65
    [3.2064][2.354533:354641]()
    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 78
    [3.2511][2.354642:354722]()
    Returns a unicode plot and a png of unique site visits, compared to 1 year ago.
    [3.2511]
    [3.2581]
    Returns a unicode plot of unique site visits, compared to 1 year ago.
  • replacement in src/FiordlandPacks.jl at line 87
    [3.2777][2.354723:354997]()
    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]
    )
    [3.2777]
    [3.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)
  • replacement in src/FiordlandPacks.jl at line 90
    [3.3024][2.354998:355299]()
    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 92
    [3.3245]
    [3.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 103
    [3.3649][2.355300:355417]()
    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 105
    [3.3748][2.355418:356192]()
    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",
    ),
    ),
    ),
    )
    [3.3748]
    [3.3850]
    save("/media/david/SSD1/FiordlandPacks/images_and_tables/visits_fiordland_packs.png")
    end
  • replacement in src/FiordlandPacks.jl at line 120
    [3.4100][2.356193:356340]()
    # gets page rank for previous 7 days
    function get_page_rank(
    end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz"
    )::DataFrame
    [3.4100]
    [3.4204]
    function get_page_rank(end_date::Dates.Date, days::Int, SITE_ID::String="fiordlandpacks.nz")::DataFrame
  • replacement in src/FiordlandPacks.jl at line 129
    [3.4579][2.356341:356443]()
    # Takes a date in string form yy-mm-dd.
    # Returns a pretty table of top 10 pages for 7, 30, 365 days.
    [3.4579]
    [3.4718]
    """
    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
    [3.5166][2.356444:356607]()
    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 154
    [3.5595][2.356608:356791]()
    e = (x -> titlecase(x))(replace(event, "+" => " "))
    if isempty(df)
    (return (Event=e, Number=0))
    else
    (return (Event=e, Number=first(df.visitors)))
    end
    [3.5595]
    [3.5746]
    e = 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
    [3.5778][2.356792:356957]()
    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 163
    [3.6210][2.356958:357141]()
    e = (x -> titlecase(x))(replace(event, "_" => " "))
    if isempty(df)
    (return (Event=e, Number=0))
    else
    (return (Event=e, Number=first(df.visitors)))
    end
    [3.6210]
    [3.6361]
    e = 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
    [3.6746][2.357142:357256]()
    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 188
    [3.7225][2.357257:357260]()
    #=
  • edit in src/FiordlandPacks.jl at line 201
    [3.7715]
    [3.7717]
  • edit in src/FiordlandPacks.jl at line 203
    [3.7718]
    [3.7718]
  • edit in src/FiordlandPacks.jl at line 249
    [3.9693]
    [3.9696]
    #=
  • edit in src/FiordlandPacks.jl at line 307
    [3.12208]
    [3.12210]