Skip to content

Commit

Permalink
Add typespecs, remove stubbed method related to #73 and #75
Browse files Browse the repository at this point in the history
Co-authored-by: Eliot Jordan <eliotjordan@users.noreply.github.com>
Co-authored-by: Shaun Ellis <sdellis@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 4, 2024
1 parent f0419c3 commit 7a3ad62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
31 changes: 9 additions & 22 deletions lib/dpul_collections/indexing_pipeline/figgy_transformer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule DpulCollections.IndexingPipeline.FiggyTransformer do
"""
alias DpulCollections.IndexingPipeline
alias DpulCollections.IndexingPipeline.FiggyTransformerProducer
alias DpulCollections.IndexingPipeline.{TransformationCacheEntry, HydrationCacheEntry}
use Broadway

@type start_opts ::
Expand Down Expand Up @@ -53,17 +54,6 @@ defmodule DpulCollections.IndexingPipeline.FiggyTransformer do
message
end

@impl Broadway
def handle_message(
_processor,
message = %Broadway.Message{data: %{data: %{"internal_resource" => "EphemeraTerm"}}},
%{cache_version: cache_version}
) do
update_linked_resources(message, cache_version)

message
end

@impl Broadway
# fallback so we acknowledge messages we intentionally don't write
@spec handle_message(any(), any(), %{required(:cache_version) => integer()}) ::
Expand All @@ -72,6 +62,13 @@ defmodule DpulCollections.IndexingPipeline.FiggyTransformer do
message
end

@impl Broadway
@spec handle_batch(any(), list(Broadway.Message.t()), any(), any()) :: list(Broadway.Message.t())
def handle_batch(_batcher, messages, _batch_info, _context) do
messages
end

@spec write_to_transformation_cache(Broadway.Message.t(), integer()) :: {:ok, %TransformationCacheEntry{} | nil}
defp write_to_transformation_cache(message, cache_version) do
hydration_cache_entry = message.data
solr_doc = transform_to_solr_document(hydration_cache_entry)
Expand All @@ -91,6 +88,7 @@ defmodule DpulCollections.IndexingPipeline.FiggyTransformer do
})
end

@spec transform_to_solr_document(%HydrationCacheEntry{}) :: %{}
defp transform_to_solr_document(hydration_cache_entry) do
%{record_id: id} = hydration_cache_entry
%{data: %{"metadata" => %{"title" => title}}} = hydration_cache_entry
Expand All @@ -100,15 +98,4 @@ defmodule DpulCollections.IndexingPipeline.FiggyTransformer do
title_ssm: title
}
end

def update_linked_resources(_message, _cache_version) do
# TODO: Implement
# In the initial case; find EphemeraFolder solr documents that contain a specific
# EphemeraTerm and update the document with the new value of the term.
end

@impl Broadway
def handle_batch(_batcher, messages, _batch_info, _context) do
messages
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ defmodule DpulCollections.IndexingPipeline.FiggyTransformerProducer do
use GenStage
@behaviour Broadway.Acknowledger


@spec start_link(integer()) :: Broadway.on_start()
def start_link(cache_version \\ 0) do
GenStage.start_link(__MODULE__, cache_version)
end
Expand All @@ -19,6 +21,7 @@ defmodule DpulCollections.IndexingPipeline.FiggyTransformerProducer do
acked_records: [HydrationCacheEntryMarker.t()],
cache_version: Integer
}
@spec init(integer()) :: {:producer, state()}
def init(cache_version) do
last_queried_marker =
IndexingPipeline.get_processor_marker!("figgy_transformer", cache_version)
Expand Down

0 comments on commit 7a3ad62

Please sign in to comment.