Compare commits

..

No commits in common. "9ee47146dbbab2a797234b7e566e6d93a500306c" and "10ef216171896a2857b36a8ac65de2a9e35fc85c" have entirely different histories.

2 changed files with 24 additions and 32 deletions

View File

@ -76,31 +76,28 @@
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const labels = [
'day_date_1',
'day_date_2',
'day_date_3',
'day_date_4',
'day_date_5',
'day_date_6',
'day_date_7',
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
];
const data = {
labels: labels,
datasets: [
{
datasets: [{
label: 'Hours we had electricity from government',
backgroundColor: 'rgb(255, 99, 132)',
borderColor: 'rgb(255, 99, 132)',
data: [offtime_1, offtime_2, offtime_3, offtime_4, offtime_5, offtime_6, offtime_7],
fill: true,
// fill: {
// target: 'origin',
// above: 'rgb(255, 0, 0)', // Area will be red above the origin
// below: 'rgb(0, 0, 255)' // And blue below the origin
//
// },
fill: {
target: 'origin',
above: 'rgb(255, 0, 0)', // Area will be red above the origin
below: 'rgb(0, 0, 255)' // And blue below the origin
},
]
}]
};
const config = {
type: 'line',

View File

@ -68,7 +68,7 @@ do
fi
if [[ $line = $lines ]]
then
time_decimal=$(echo $(date -d "$total_time" +'%H' | bc).$(($(date -d "$total_time" +'%M' | bc) * 100 / 60)))
time_decimal=$(echo $(date -d "$total_time" +'%H').$(($(date -d "$total_time" +'%M') * 100 / 60)))
echo "$current_date,$time_decimal" >> days.csv
fi
fi
@ -83,22 +83,17 @@ while read in
do
hours=$(echo $in | cut -d, -f2)
line=$(( $line + 1 ))
date_var=$(echo $in | cut -d, -f1)
if [[ $line > $line_start ]]
then
day_num=$(( $day_num + 1 ))
if [[ $day_num = 1 ]]; then day_1=$(echo $hours | sed "s/0//"); day_date_1=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 2 ]]; then day_2=$(echo $hours | sed "s/0//"); day_date_2=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 3 ]]; then day_3=$(echo $hours | sed "s/0//"); day_date_3=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 4 ]]; then day_4=$(echo $hours | sed "s/0//"); day_date_4=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 5 ]]; then day_5=$(echo $hours | sed "s/0//"); day_date_5=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 6 ]]; then day_6=$(echo $hours | sed "s/0//"); day_date_6=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 7 ]]; then day_7=$(echo $hours | sed "s/0//"); day_date_7=$(echo $date_var | sed 's/\//\\\//g'); fi
if [[ $day_num = 1 ]]; then day_1=$(echo $hours | sed "s/0//"); fi
if [[ $day_num = 2 ]]; then day_2=$(echo $hours | sed "s/0//"); fi
if [[ $day_num = 3 ]]; then day_3=$(echo $hours | sed "s/0//"); fi
if [[ $day_num = 4 ]]; then day_4=$(echo $hours | sed "s/0//"); fi
if [[ $day_num = 5 ]]; then day_5=$(echo $hours | sed "s/0//"); fi
if [[ $day_num = 6 ]]; then day_6=$(echo $hours | sed "s/0//"); fi
if [[ $day_num = 7 ]]; then day_7=$(echo $hours | sed "s/0//"); fi
fi
done < days.csv
hours_so_far=$(($(TZ='Asia/Beirut' date +'%H') - $(echo $day_7. | cut -d. -f1)))
cat stats.html | sed "s/offtime_1/$day_1/" | sed "s/offtime_2/$day_2/"| sed "s/offtime_3/$day_3/" | sed "s/offtime_4/$day_4/" | sed "s/offtime_5/$day_5/" | sed "s/offtime_6/$day_6/" | sed "s/offtime_7/$day_7/" | sed "s/hours_so_far_day/$hours_so_far/" | sed "s/day_date_1/$day_date_1/" | sed "s/day_date_2/$day_date_2/" | sed "s/day_date_3/$day_date_3/" | sed "s/day_date_4/$day_date_4/" | sed "s/day_date_5/$day_date_5/" | sed "s/day_date_6/$day_date_6/" | sed "s/day_date_7/$day_date_7/" > /usr/local/apache2/htdocs/stats/index.html
chown daemon:daemon /usr/local/apache2/htdocs/stats/index.html
cat stats.html | sed "s/offtime_1/$day_1/" | sed "s/offtime_2/$day_2/"| sed "s/offtime_3/$day_3/" | sed "s/offtime_4/$day_4/" | sed "s/offtime_5/$day_5/" | sed "s/offtime_6/$day_6/" | sed "s/offtime_7/$day_7/" > stats/index.html