diff --git a/app/config/dev.exs b/app/config/dev.exs index d0a9ecd7f..bfa8a39f4 100644 --- a/app/config/dev.exs +++ b/app/config/dev.exs @@ -124,6 +124,7 @@ if prefix = System.get_env("DEV_PREFIX") do end config :meadow, :sitemaps, + base_url: "https://dc.library.northwestern.edu/", gzip: false, store: Sitemapper.FileStore, sitemap_url: "https://devbox.library.northwestern.edu:3333/", diff --git a/app/config/releases.exs b/app/config/releases.exs index 0b2dafcbc..b1d9d47b4 100644 --- a/app/config/releases.exs +++ b/app/config/releases.exs @@ -105,7 +105,9 @@ config :meadow, bucket: aws_secret("meadow", dig: ["buckets", "sitemap"]), path: "/" ], - sitemap_url: aws_secret("meadow", dig: ["dc", "base_url"]) + base_url: aws_secret("meadow", dig: ["dc", "base_url"]), + sitemap_url: + aws_secret("meadow", dig: ["dc", "base_url"], apply: &{:ok, Path.join(&1, "api/sitemap")}) ], validation_ping_interval: environment_secret("VALIDATION_PING_INTERVAL", default: "1000") @@ -125,7 +127,12 @@ config :meadow, Meadow.Scheduler, overlap: false, timezone: "America/Chicago", jobs: [ - # Runs daily at the configured time (default: 2AM Central) + # Sitemap generation runs daily at the configured time (default: 1AM Central) + { + aws_secret("meadow", dig: ["scheduler", "sitemap"], default: "0 1 * * *"), + {Meadow.Utils.Sitemap, :generate, []} + }, + # Preservation check runs daily at the configured time (default: 2AM Central) { aws_secret("meadow", dig: ["scheduler", "preservation_check"], default: "0 2 * * *"), {Meadow.Data.PreservationChecks, :start_job, []} diff --git a/app/config/test.exs b/app/config/test.exs index 551fc23bf..46e977fbd 100644 --- a/app/config/test.exs +++ b/app/config/test.exs @@ -119,6 +119,7 @@ config :honeybadger, config :meadow, :sitemaps, gzip: true, store: Sitemapper.S3Store, + base_url: "http://localhost:3333/", sitemap_url: "http://localhost:3333/", store_config: [bucket: prefix("uploads"), path: ""] diff --git a/app/lib/meadow/utils/sitemap.ex b/app/lib/meadow/utils/sitemap.ex index 72ec49d30..367220df2 100644 --- a/app/lib/meadow/utils/sitemap.ex +++ b/app/lib/meadow/utils/sitemap.ex @@ -2,9 +2,12 @@ defmodule Meadow.Utils.Sitemap do @moduledoc """ Generate and upload Digital Collection sitemaps """ - alias Meadow.Data.{Collections, Works} + alias Meadow.Data.Collections + alias Meadow.Data.Schemas.Work alias Meadow.Repo + import Ecto.Query + require Logger @doc """ @@ -74,7 +77,7 @@ defmodule Meadow.Utils.Sitemap do end defp work_urls do - Works.work_query(visibility: "OPEN", work_type: "IMAGE") + from(w in Work, where: w.visibility["id"] == ^"OPEN" and w.published) |> Repo.stream() |> Stream.map(fn %{id: id, updated_at: updated_at} -> %Sitemapper.URL{ @@ -88,7 +91,7 @@ defmodule Meadow.Utils.Sitemap do defp expand_url(path) do config() - |> Keyword.get(:sitemap_url) + |> Keyword.get(:base_url) |> URI.parse() |> URI.merge(path) |> URI.to_string()