generated from kamangir/blue-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
firms ingest refactor - kamangir/bolt#746
- Loading branch information
Showing
6 changed files
with
96 additions
and
9 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_ingest() { | ||
local task=$(abcli_unpack_keyword $1 help) | ||
|
||
if [ "$task" == "help" ]; then | ||
blue_geo_ingest_firms "$@" | ||
return | ||
fi | ||
|
||
local function_name=blue_geo_ingest_$task | ||
if [[ $(type -t $function_name) == "function" ]]; then | ||
$function_name "${@:2}" | ||
return | ||
fi | ||
|
||
abcli_log_error "-blue_geo: ingest: $task: command not found." | ||
return 1 | ||
} | ||
|
||
abcli_source_path - caller,suffix=/ingest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_ingest_firms() { | ||
local options=$1 | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
options="dryrun,~upload" | ||
local date=$(abcli_string_timestamp_short \ | ||
--include_time 0 \ | ||
--unique 0) | ||
local area=$(python3 -m blue_geo.firms.api.area \ | ||
get \ | ||
--what area \ | ||
--delim \|) | ||
local source=$(python3 -m blue_geo.firms.api.area \ | ||
get \ | ||
--what source \ | ||
--values 1 \ | ||
--delim \|) | ||
local args="[--date $date]$ABCUL[depth 1]$ABCUL[--area $area]$ABCUL[--source $source]$ABCUL[--log 1]" | ||
abcli_show_usage "blue_geo ingest firms$ABCUL[$options]$ABCUL[.|<object-name>]$ABCUL$args" \ | ||
"firms -ingest-> <object-name>." | ||
return | ||
fi | ||
|
||
local do_dryrun=$(abcli_option_int "$options" dryrun 0) | ||
local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun)) | ||
|
||
local object_name=$(abcli_clarify_object $2 .) | ||
|
||
abcli_eval dryrun=$do_dryrun \ | ||
python3 -m blue_geo.firms.api.area \ | ||
ingest \ | ||
--object_name $object_name \ | ||
"${@:4}" | ||
|
||
[[ "$do_dryrun" == 1 ]] && | ||
abcli_upload - $object_name | ||
|
||
return 0 | ||
} |
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
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
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