-
-
Save mrdotb/112c09ea7d1e5895cfd4746f8e7d80ad to your computer and use it in GitHub Desktop.
model.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule App.Print do | |
@behaviour App.Recover.Impl | |
@table_name "prints" | |
import Ecto.Query, only: [from: 2] | |
alias App.{Repo, Teams} | |
alias App.Schemas.Print | |
alias App.Teams.Recover.Helpers | |
@impl true | |
def dump([team, terminal_id]) do | |
query = | |
from(p in Print, | |
where: p.terminal_id == ^terminal_id, | |
order_by: p.inserted_at, | |
select: p | |
) | |
Repo.all(query, prefix: Teams.team_prefix(team)) | |
|> Enum.map(&map(&1)) | |
end | |
@impl true | |
def map(p) do | |
[ | |
id: p.id, | |
count: p.count, | |
type: p.type, | |
terminal_id: p.terminal_id, | |
print_date: Helpers.cast(p.print_date), | |
transaction_id: p.transaction_id, | |
prev_id: p.prev_id, | |
next_id: p.next_id, | |
hash: "", | |
synced: Helpers.cast(true) | |
] | |
end | |
@impl true | |
def table_name, do: @table_name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment