Skip to content

Commit

Permalink
add support for arbitrarily many tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ecly committed Jun 16, 2018
1 parent 8cf9956 commit ba5b573
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 8 additions & 2 deletions config/prod.secret.example.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ config :ex_aws,

config :image_tagger, update_interval_seconds: 1
config :image_tagger, bucket_name: "bucket"

config :image_tagger, image_folder: "to_review"
config :image_tagger, bad_folder: "bad"
config :image_tagger, good_folder: "good"

# Various tags. The tag should atom should correspond
# to the atom represention of the 'tag' that the front-end
# pushes through the channel when the reviewer submits a review.
# Can be arbitrarily many tags.
config :image_tagger, bad: "bad"
config :image_tagger, good: "good"
14 changes: 4 additions & 10 deletions lib/image_tagger/review_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,14 @@ defmodule ImageTagger.ReviewServer do
end

@doc """
Archives the given image, copying it to the 'bad' folder.
Archives the given image, copying it to the folder associated
with the given tag.
"""
def archive_image(image, :good) do
folder = Application.fetch_env!(:image_tagger, :good_folder)
def archive_image(image, tag) when is_atom(tag) do
folder = Application.fetch_env!(:image_tagger, tag)
move_image_to_folder(image, folder)
end

@doc """
Archives the given image, copying it to the 'good' folder.
"""
def archive_image(image, :bad) do
folder = Application.fetch_env!(:image_tagger, :bad_folder)
move_image_to_folder(image, folder)
end

@doc """
Adds an image to the ReviewServer signifying that it
Expand Down

0 comments on commit ba5b573

Please sign in to comment.