Skip to content

Commit

Permalink
Add Quality check - take 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpursley committed Dec 29, 2023
1 parent 50e9428 commit 8bfff30
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@ walex-*.tar
.elixir_ls/

# VSCode
.vscode/

.tool-versions
.vscode/
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
erlang 26.1.2
elixir 1.15.7-otp-26
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,9 @@ More destinations coming. Pull requests welcome!

You'll need a local Postgres setup with:

- hostname: "localhost"
- username: "postgres"
- password: "postgres"
hostname: "localhost", username: "postgres", password: "postgres"

- Create the "todos_test" database: `mix set_up_test_database`
- Run tests: `mix test`
- Delete test database: `mix tear_down_test_database`
Create the "todos_test" database: `mix set_up_test_database`
Run tests: `mix test`
Check quality: `mix quality`
Delete test database: `mix tear_down_test_database`
10 changes: 5 additions & 5 deletions lib/walex/transaction_filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ defmodule WalEx.TransactionFilter do
def filter_changes(%Transaction{changes: changes}, table, type, app_name) do
changes
|> subscribes_and_has_table(table, app_name)
|> Enum.filter(&is_type?(&1, type))
|> Enum.filter(&record_type?(&1, type))
end

defp subscribes_and_has_table(changes, table, app_name) do
Expand All @@ -163,10 +163,10 @@ defmodule WalEx.TransactionFilter do

def has_table?(_txn, _table_name), do: false

def is_type?(%NewRecord{type: "INSERT"}, :insert), do: true
def is_type?(%UpdatedRecord{type: "UPDATE"}, :update), do: true
def is_type?(%DeletedRecord{type: "DELETE"}, :delete), do: true
def is_type?(_txn, _type), do: false
def record_type?(%NewRecord{type: "INSERT"}, :insert), do: true
def record_type?(%UpdatedRecord{type: "UPDATE"}, :update), do: true
def record_type?(%DeletedRecord{type: "DELETE"}, :delete), do: true
def record_type?(_txn, _type), do: false

def filter_unwatched_fields(events, unwatched_changes) do
Enum.filter(events, &unwatched_fields?(&1, unwatched_changes))
Expand Down

0 comments on commit 8bfff30

Please sign in to comment.