moving old code
This commit is contained in:
98
old_code/retail_monthly_job_load.sh
Executable file
98
old_code/retail_monthly_job_load.sh
Executable file
@@ -0,0 +1,98 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
#Declare the Associative array
|
||||
declare -A credentials
|
||||
|
||||
HOME_DIR=$HOME
|
||||
echo $HOME_DIR
|
||||
CONF_DIR=$HOME_DIR/conf
|
||||
|
||||
#Server credentials file path
|
||||
input_file=$CONF_DIR/server_credentials.txt
|
||||
|
||||
#Read the credentials from the server_credentials from conf folders
|
||||
#Remove Blank lines and comment starting with #
|
||||
while IFS="=" read -r key value; do
|
||||
credentials[$key]=$value
|
||||
done < <(sed -e '/^\s*$/ d' -e '/^#/ d' $input_file)
|
||||
|
||||
#CODS credentials
|
||||
host=${credentials[host]}
|
||||
echo ${credentials[host]}
|
||||
user=${credentials[user]}
|
||||
echo ${credentials[user]}
|
||||
pwd=${credentials[password]}
|
||||
echo ${credentials[password]}
|
||||
port=${credentials[port]}
|
||||
dbname=${credentials[dbname1]}
|
||||
|
||||
#let i=0
|
||||
#set -A arr
|
||||
#BASE_CODS_ARGUMENTS="--host=$cods_host --user=$cods_user --password=$cods_pwd --port=$3306"
|
||||
#BASE_ODS_ARGUMENTS="--user=$user --password=$pwd --host=$host"
|
||||
psql_base_arg="postgresql://$user:$pwd@$host/$dbname"
|
||||
#psql_base_arg="postgresql://postgres:j3(jLBq}e@localhost/ffm_k2"
|
||||
echo $psql_base_arg
|
||||
|
||||
#ifStart=`date '+%d'`
|
||||
ifStart="01"
|
||||
echo "$ifStart"
|
||||
|
||||
|
||||
#Check today is sunday. Scheduling weekly job
|
||||
today="$(date +%a)"
|
||||
sun="Mon"
|
||||
|
||||
#inserting into fw_core.fw_jobctl_runschedule
|
||||
chkrun=$(psql $psql_base_arg -t -c "select count(*) from fw_core.fw_jobctl_jobstep_master where client_id=10 and function_id=1 and run_frequency='monthly' and active_flag=true;")
|
||||
echo "chkrun is $chkrun"
|
||||
if [[ $chkrun -gt 0 ]]; then
|
||||
echo "continuing";
|
||||
psql $psql_base_arg -c "INSERT INTO fw_core.fw_jobctl_runschedule
|
||||
(client_id, function_id, run_schedule_date, run_frequency, start_time, begin_status, created_by, updated_by, create_timestamp, update_timestamp)
|
||||
select client_id, function_id,now(),run_frequency,now(),'started','developer','developer',now(),now() from fw_core.fw_jobctl_jobstep_master
|
||||
where active_flag='TRUE' group by client_id, function_id, run_frequency limit 1;"
|
||||
|
||||
else
|
||||
echo " No active job for monthly for client_id=10"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
while IFS="|" read -a line
|
||||
do
|
||||
run_frequency=${line[0]}
|
||||
job_scheduling_day="${line[1]}"
|
||||
|
||||
echo "$run_frequency"
|
||||
echo "$job_scheduling_day"
|
||||
if [ $run_frequency == "daily" ] ; then
|
||||
echo "Populating daily job into fw_jobctl_runschedule_jobstep"
|
||||
|
||||
psql $psql_base_arg -c"insert into fw_core.fw_jobctl_runschedule_jobstep(client_id, function_id,run_schedule_id, run_frequency, job_id, step_id, job_step_run_dependency_seuqence, job_name, step_name,job_script,job_function_name,job_fun_param, job_scope, job_scope_qualifier, run_schedule_date,data_from_date, data_to_date, create_timestamp, update_timestamp,latest_flag)
|
||||
select a.client_id, a.function_id, b.syspk,a.run_frequency, job_id, step_id, job_step_run_dependency_seuqence, job_name, step_name, job_script,job_function_name,job_fun_param,
|
||||
job_scope, job_scope_qualifier, now(),current_date,current_date,now(),now(),true
|
||||
from fw_core.fw_jobctl_jobstep_master a join fw_core.fw_jobctl_runschedule b
|
||||
on a.client_id=b.client_id and a.function_id=b.function_id and a.run_frequency=b.run_frequency and b.begin_status = 'started' and b.end_status is null
|
||||
where a.active_flag='true' and a.run_frequency='daily' and a.job_scheduling_day='daily'
|
||||
order by a.client_id,a.function_id,a.job_id,a.step_id,a.job_step_run_dependency_seuqence;"
|
||||
|
||||
elif [ $run_frequency == "monthly" ] && [ $ifStart == "$job_scheduling_day" ] ; then
|
||||
echo "Populating monthly job into fw_jobctl_runschedule_jobstep"
|
||||
|
||||
psql $psql_base_arg -c"insert into fw_core.fw_jobctl_runschedule_jobstep(client_id, function_id, run_frequency, job_id, step_id, job_step_run_dependency_seuqence, job_name, step_name,job_script,job_function_name,job_fun_param, job_scope, job_scope_qualifier, run_schedule_id,run_schedule_date,data_from_date, data_to_date, create_timestamp, update_timestamp,latest_flag)
|
||||
select client_id, function_id, run_frequency, job_id, step_id, job_step_run_dependency_seuqence, job_name, step_name, job_script,job_function_name,job_fun_param,
|
||||
job_scope, job_scope_qualifier, row_number() over (),now(),current_date,current_date,now(),now(),true
|
||||
from fw_core.fw_jobctl_jobstep_master where active_flag='true' and run_frequency='$run_frequency' and job_scheduling_day='$job_scheduling_day' order by client_id,function_id,job_id,step_id,job_step_run_dependency_seuqence;"
|
||||
|
||||
elif [ $run_frequency == "weekly" ] && [ "${today}" = "$job_scheduling_day" ] ; then
|
||||
echo "Populating weekly job into fw_jobctl_runschedule_jobstep"
|
||||
|
||||
psql $psql_base_arg -c"insert into fw_core..fw_jobctl_runschedule_jobstep(client_id, function_id, run_frequency, job_id, step_id, job_step_run_dependency_seuqence, job_name, step_name,job_script,job_function_name,job_fun_param, job_scope, job_scope_qualifier, run_schedule_id,run_schedule_date,data_from_date, data_to_date, create_timestamp, update_timestamp,latest_flag)
|
||||
select client_id, function_id, run_frequency, job_id, step_id, job_step_run_dependency_seuqence, job_name, step_name, job_script,job_function_name,job_fun_param,
|
||||
job_scope, job_scope_qualifier, row_number() over (),now(),current_date,current_date,now(),now(),true
|
||||
from fw_core.fw_jobctl_jobstep_master where active_flag='true' and run_frequency='$run_frequency' and job_scheduling_day='$job_scheduling_day' order by client_id,function_id,job_id,step_id,job_step_run_dependency_seuqence;"
|
||||
|
||||
fi
|
||||
done < <(psql $psql_base_arg -At -c"select distinct run_frequency,job_scheduling_day from fw_core.fw_jobctl_jobstep_master where active_flag=true order by run_frequency ")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user