     text(conn, "Missing secret – please visit /api/events?secret=thethingigotfromben")
   end
 
+  def is_in_future?(ev) do
+    case DateTime.from_iso8601(ev.start_date) do
+      {:ok, dt, _} -> Timex.now() |> Timex.before?(dt)
+      _ -> false
+    end
+  end
+
   def client,
     do:
       OsdiClient.build_client(


  def secret, do: Application.get_env(:admin, :osdi_api_token)

  def internal_events_api(conn, %{"secret" => input_secret}) do
    if secret() == input_secret do
      events =
        OsdiClient.stream(client(), "events")
        |> Enum.map(&Admin.EventsChannel.event_pipeline/1)
        |> Enum.map(fn ev ->
          tags = Map.get(ev, "tags", [])

          candidate_tag =
            Enum.filter(

              "Calendar: " <> c -> c
            end

          flags =
            %{}
            |> Map.put("direct_publish", Enum.member?(tags, "Source: Direct Publish"))
            |> Map.put("synced", Enum.member?(tags, "Source: Sync"))
            |> Map.put("editable", not Enum.member?(tags, "Source: Sync"))
            |> Map.put("local_chapter", Enum.member?(tags, "Calendar: Local Chapter"))
            |> Map.put("candidate", candidate)

          Map.merge(ev, flags)
        end)

      json(conn, events)
