-
Notifications
You must be signed in to change notification settings - Fork 0
/
displayStatus.sh
111 lines (101 loc) · 4.91 KB
/
displayStatus.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
#Global variable to keep record when core used last time
declare -a submitted_mentee_details
function displayStatus(){
if [[ $(whoami) == "core" ]]; then
#for command line argument
domain="$1"
declare -A submitted_web=( [task_01]=0 [task_02]=0 [task_03]=0 )
declare -A submitted_app=( [task_01]=0 [task_02]=0 [task_03]=0 )
declare -A submitted_sysad=( [task_01]=0 [task_02]=0 [task_03]=0 )
declare -A menteeCount_domain=( [Webdev]=0 [Appdev]=0 [Sysad]=0)
declare -a current_submitted_mentee_details
#changed output from last time core used this alias
declare -a changed
#changed output filtered by domain
declare -a changed_web
declare -a changed_app
declare -a changed_sysad
#logic: submitted means task directory exist ; domain directory exist, then add one in total count
while read line1
do
name=$(echo "$line1" | cut -d " " -f 2)
for i in Webdev Appdev Sysad;do
for j in task_01 task_02 task_03;do
if [[ -d /home/core/mentees/$name/$i/$j/ ]]; then
case $i in
"Webdev") ((submitted_web[$j]+=1));;
"Appdev") ((submitted_app[$j]+=1));;
"Sysad") ((submitted_sysad[$j]+=1));;
*) ;;
esac
current_submitted_mentee_details+=("$name-$i-$j")
fi
done
if [[ -d /home/core/mentees/$name/$i/ ]]; then
((menteeCount_domain[$i]+=1))
fi
done
done < /home/core/mentees_domain.txt
#global variable updated and changes detected
for element in "${current_submitted_mentee_details[@]}";do
if ! [[ ${submitted_mentee_details[*]} == *" $element "* ]];then
submitted_mentee_details+=("$element")
changed+=("$element")
fi
done
for element1 in "${changed[@]}";do
if [[ $element1 == *"Webdev"* ]];then
changed_web+=("$element1")
fi
done
for element2 in "${changed[@]}";do
if [[ $element2 == *"Appdev"* ]];then
changed_app+=("$element2")
fi
done
for element3 in "${changed[@]}";do
if [[ $element3 == *"Sysad"* ]];then
changed_sysad+=("$element3")
fi
done
#Looks big, it's just coz of long names. Just calculating percentage and output given based on arguement
case $domain in
"")
echo "Submitted Percentage
Task 1: $(( submitted_web[task_01]+submitted_app[task_01]+submitted_sysad[task_01]*100/menteeCount_domain[Webdev]+menteeCount_domain[Appdev]+menteeCount_domain[Sysad])) %
Task 2: $(( submitted_web[task_02]+submitted_app[task_02]+submitted_sysad[task_02]*100/menteeCount_domain[Webdev]+menteeCount_domain[Appdev]+menteeCount_domain[Sysad])) %
Task 3: $(( submitted_web[task_03]+submitted_app[task_03]+submitted_sysad[task_03]*100/menteeCount_domain[Webdev]+menteeCount_domain[Appdev]+menteeCount_domain[Sysad])) %
Mentees who submitted task since last visited: "
echo "${changed[@]}"
;;
"Webdev")
echo "Submitted Percentage for Webdev
Task 1: $(( submitted_web[task_01]*100/menteeCount_domain[Webdev])) %
Task 2: $(( submitted_web[task_02]*100/menteeCount_domain[Webdev])) %
Task 3: $(( submitted_web[task_03]*100/menteeCount_domain[Webdev])) %
Mentees who submitted task in Webdev domain since last visited: "
echo "${changed_web[@]}"
;;
"Appdev")
echo "Submitted Percentage for Appdev
Task 1: $(( submitted_app[task_01]*100/menteeCount_domain[Appdev])) %
Task 2: $(( submitted_app[task_02]*100/menteeCount_domain[Appdev])) %
Task 3: $(( submitted_app[task_03]*100/menteeCount_domain[Appdev])) %
Mentees who submitted task in Appdev domain since last visited: "
echo "${changed_app[@]}"
;;
"Sysad")
echo "Submitted Percentage for Sysad
Task 1: $(( submitted_sysad[task_01]*100/menteeCount_domain[Sysad])) %
Task 2: $(( submitted_sysad[task_02]*100/menteeCount_domain[Sysad])) %
Task 3: $(( submitted_sysad[task_03]*100/menteeCount_domain[Sysad])) %
Mentees who submitted task in Sysad domain since last visited: "
echo "${changed_sysad[@]}"
;;
*);;
esac
fi
}
alias displayStatus='displayStatus'
#use this alias like displayStatus (or) displayStatus Sysad