Skip to content

Commit

Permalink
refactor: clean code.
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Sep 17, 2024
1 parent 7ac7257 commit 130b5df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"decrypt": "./bin/decrypt",
"encrypt": "./bin/encrypt",
"db:build": "./bin/build-db && npm run db:check",
"db:check": "elm make src/CheckDb.elm --output=check-db-app.js 1> /dev/null && node check-db.js",
"db:check": "elm make src/CheckDb.elm --optimize --output=check-db-app.js 1> /dev/null && node check-db.js",
"lint:openapi": "npx swagger-cli validate openapi.yaml",
"lint:prettier": "prettier --config .prettierrc --check",
"lint:prettier:all": "npm run lint:prettier -- .",
Expand Down
24 changes: 12 additions & 12 deletions src/CheckDb.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
port module CheckDb exposing (main)

import Static.Db as StaticDb
import Static.Db as StaticDb exposing (Db)
import Static.Json as StaticJson


Expand All @@ -10,15 +10,15 @@ type alias Flags =
}


checkDbs : Flags -> Result String StaticDb.Db
checkDbs detailedRawProcessesJson =
StaticDb.db StaticJson.rawJsonProcesses
|> Result.mapError (\err -> "Non-detailed Db is invalid: " ++ err)
|> Result.andThen
(StaticDb.db detailedRawProcessesJson
|> Result.mapError (\err -> "Detailed Db is invalid: " ++ err)
|> always
)
checkDbs : Flags -> Result String ( Db, Db )
checkDbs detailedRawJsonProcesses =
Result.map2 Tuple.pair
(StaticDb.db StaticJson.rawJsonProcesses
|> Result.mapError (\err -> "Non-detailed Db is invalid: " ++ err)
)
(StaticDb.db detailedRawJsonProcesses
|> Result.mapError (\err -> "Detailed Db is invalid: " ++ err)
)


main : Program Flags () ()
Expand All @@ -29,10 +29,10 @@ main =
( ()
, case checkDbs flags of
Err error ->
logAndExit { message = "Db is dubious: " ++ error, status = 1 }
logAndExit { message = error, status = 1 }

Ok _ ->
logAndExit { message = "Db is fine", status = 0 }
logAndExit { message = "Dbs look fine", status = 0 }
)
, subscriptions = always Sub.none
, update = \_ _ -> ( (), Cmd.none )
Expand Down

0 comments on commit 130b5df

Please sign in to comment.