Skip to content

Latest commit

 

History

History
180 lines (136 loc) · 3.81 KB

v_graph.livemd

File metadata and controls

180 lines (136 loc) · 3.81 KB

Velocity Graph

Mix.install([
  {:kino, "~> 0.7.0"},
  {:vega_lite, "~> 0.1.6"},
  {:kino_vega_lite, "~> 0.1.4"}
])

Class Helpers

defmodule Class do
  @today Date.utc_today()
  @launch_deadline ~D[2023-01-31]
  @beta_deadline ~D[2022-12-20]
  @initial_class_date ~D[2022-10-20]
  @initial_class_day 17
  @completed_content_days 19
  @actual_class_day 17
  def beta_class_days_remaining(date \\ @today, count \\ 0)
  def beta_class_days_remaining(@beta_deadline, count), do: count

  def beta_class_days_remaining(current, count) do
    beta_class_days_remaining(Date.add(current, 1), (has_lesson?(current) && count + 1) || count)
  end

  def beta_target_days_completed(target) do
    total_days_of_content() - beta_class_days_remaining(target)
  end

  def beta_expected_end_date(current \\ @today, count \\ beta_days_of_content_remaining())
  def beta_expected_end_date(end_date, 0), do: end_date

  def beta_expected_end_date(current, count) do
    beta_expected_end_date(Date.add(current, 1), (has_lesson?(current) && count - 1) || count)
  end

  def beta_days_of_content_remaining, do: total_days_of_content() - @actual_class_day

  def beta_actual_days_completed, do: @actual_class_day
  def completed_content_days, do: @completed_content_days

  def days_in_cohort, do: 5 * 4 * 3

  def days_completed_balanced_target(target) do
    days_since_starting = Date.diff(target, @initial_class_date)

    Float.ceil(days_since_starting * days_unfinished() / total_days_remaining_until_deadline()) +
      @initial_class_day
  end

  def days_ahead_or_behind_in_beta, do: total_days_of_content() - beta_class_days_remaining()

  def total_days_remaining_until_deadline, do: Date.diff(@launch_deadline, @today)

  def total_days_of_content do
    outline = File.read!(__DIR__ <> "/start.livemd")
    Regex.scan(~r/(\#{3})(.+)/, outline) |> Enum.count()
  end

  def days_needing_content_review,
    do: total_days_of_content() - @completed_content_days - days_needing_content()

  def days_needing_content do
    outline = File.read!(__DIR__ <> "/start.livemd")

    Regex.scan(~r/\#{3}[^\#]+/, outline)
    |> Enum.filter(fn [section] ->
      Regex.scan(~r/\*.+/, section)
      |> Enum.reject(fn [bullet] ->
        bullet in ["* Reading", "* Exercises"] or
          Regex.match?(~r/\[.+(?=\])/, bullet)
      end)
      |> Enum.any?()
    end)
    |> Enum.count()
  end

  def days_unfinished, do: days_needing_content_review() + days_needing_content()

  defp has_lesson?(date) do
    Calendar.strftime(date, "%A") in ["Monday", "Tuesday", "Wednesday", "Thursday", "Sunday"]
  end
end

Content Tracking

General Information

Class.days_in_cohort()
# days needing content + days needing content review
Class.days_unfinished()
Class.days_needing_content()
Class.days_needing_content_review()
Class.total_days_remaining_until_deadline()

Targets

# October
Class.days_completed_balanced_target(~D[2022-10-31])
# November
Class.days_completed_balanced_target(~D[2022-11-30])
# December
Class.days_completed_balanced_target(~D[2022-12-31])
# January
Class.days_completed_balanced_target(~D[2023-01-31])

Beta Tracking

General Information

Class.beta_class_days_remaining()
Class.beta_days_of_content_remaining()
Class.beta_actual_days_completed()

Targets

# Current
Class.beta_target_days_completed(Date.utc_today())
Class.beta_target_days_completed(~D[2022-10-24])
# October
Class.beta_target_days_completed(~D[2022-10-31])
# October
Class.beta_target_days_completed(~D[2022-11-30])
# October
Class.beta_target_days_completed(~D[2022-12-20])
Class.beta_expected_end_date()