latest_mmt_version

This commit is contained in:
Deepthi
2021-06-21 12:35:07 +05:30
parent 559fa36e6a
commit b4d396929e
425 changed files with 65022 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
#!/bin/bash -e
#!/bin/bash -e
HOME="/home/compegence/customer"
#Directories
homeDir=$HOME/MMT
configDir=$homeDir/conf
input_file=$configDir/etl-config.txt
declare -A credentials
while IFS="=" read -r key value; do
credentials[$key]=$value
done < <( sed -e '/^\s*$/ d' -e '/^#/ d' $input_file )
for i in ${credentials[@]}; do echo ***$i; done
user=${credentials[user]}
password=${credentials[password]}
host=${credentials[host]}
#db=${credentials[db]}
protocol=${credentials[protocol]}
server=${credentials[server]}
db="mmt_intv1"
#mmt_con="psql -X -A -t postgresql://$user:$password@$host/$db?options=--search_path%3D"
#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:$password@$host/$db"
#psql_base_arg="postgresql://postgres:j3(jLBq}e@localhost/ffm_k2"
echo $psql_base_arg
ifStart=`date '+%d'`
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=21 and function_id=1 and run_frequency='daily' 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_timestamp, run_frequency, start_time, begin_status, created_by, updated_by, create_timestamp, update_timestamp)
select client_id, function_id,now(),run_frequency,now(),'started','Admin','Admin',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 daily for client_id=4"
exit 1;
fi
# looping fw_jobctl_jobstep_master for active records
while IFS="|" read -a line
do
run_frequency=${line[2]}
#job_scheduling_day="${line[1]}"
echo "$run_frequency"
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,latest_runschedule_flag,run_schedule_id,run_schedule_timestamp, run_frequency, job_id, step_id, job_step_run_dependency_seuqence,
job_script_type,job_step_script_name,job_fun_param_array,job_name, step_name, job_scope, job_scope_qualifier_array, created_by,updated_by, create_timestamp, update_timestamp)
select a.client_id, a.function_id,b.latest_runschedule_flag, b.run_schedule_id,b.run_schedule_timestamp,a.run_frequency, a.job_id, a.step_id, a.job_step_run_dependency_seuqence,
a.job_script_type,a.job_step_script_name,a.job_fun_param_array,a.job_name,a.step_name,a.job_scope, a.job_scope_qualifier_array, 'Admin','Admin',now(),now()
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
where latest_runschedule_flag='1' and b.begin_status = 'started' and b.end_status is null and a.active_flag='true' and a.run_frequency='daily'
order by a.client_id,a.function_id,a.job_id,a.step_id,a.job_step_run_dependency_seuqence;"
fi
done < <(psql $psql_base_arg -At -c"select distinct client_id,function_id,run_frequency from fw_core.fw_jobctl_jobstep_master order by run_frequency ")