- Fix Oban self-scheduling chain silently dying (remove unique constraint so after block can schedule next job)
- Fix Natchez and TrueShotAmmo extract_price defaulting to 0 for missing price data
- Fix caliber_matcher redundant String.downcase inside Enum.find (pre-downcase outside loop)
- Fix runner.ex double iteration (Enum.map + Enum.count merged into single Enum.reduce)
- Fix price_stats_for_caliber firing 3 queries instead of 2 (merge all_time + thirty_day via FILTER)
- Fix PSA duplicate Floki.find on same selector (merge extract_title + extract_url)
- Fix PubSub broadcast carrying no caliber IDs (now includes IDs; clients skip irrelevant reloads)
- Fix BulkAmmo ^ anchor skipping non-leading round counts
- Fix TargetSportsUSA fragile exact text match 'Add To Cart' (use case-insensitive contains)
- Fix SgAmmo dead destructure {_, _, _} = row
- Fix text_detector brass/nickel detection order
- Fix Natchez GraphQL string interpolation (add escape_gql_string)
- Fix chart data triple Enum.map merged into single reduce
- Change Oban scraping queue workers from 2 to 1 (only one needed with Process.sleep)
20 lines
557 B
Elixir
20 lines
557 B
Elixir
defmodule Ammoprices.Scraping.TextDetector do
|
|
@moduledoc false
|
|
|
|
def detect_subsonic(nil), do: false
|
|
def detect_subsonic(title), do: Regex.match?(~r/sub[\-\s]?sonic/i, title)
|
|
|
|
def detect_casing(nil), do: nil
|
|
|
|
def detect_casing(title) do
|
|
downcased = String.downcase(title)
|
|
|
|
cond do
|
|
String.contains?(downcased, "steel") -> "steel"
|
|
String.contains?(downcased, "aluminum") -> "aluminum"
|
|
String.contains?(downcased, "brass") -> "brass"
|
|
String.contains?(downcased, "nickel") -> "brass"
|
|
true -> nil
|
|
end
|
|
end
|
|
end
|