Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tchncs-scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Milan
tchncs-scripts
Commits
ee6dd52d
Commit
ee6dd52d
authored
1 year ago
by
Milan
Browse files
Options
Downloads
Patches
Plain Diff
fix goals.sh
parent
36921d80
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
donate-insights/src/goals.sh
+88
-0
88 additions, 0 deletions
donate-insights/src/goals.sh
with
88 additions
and
0 deletions
donate-insights/src/goals.sh
0 → 100644
+
88
−
0
View file @
ee6dd52d
#!/bin/bash
set
-e
avg_past3
=
$(
echo
"scale=2; ((
$month1_spent
+
$month2_spent
+
$month3_spent
) / 3) * -1"
| bc
-l
)
goal1_percentage
=
$(
bc
-l
<<<
"scale=2; (
${
month0_donated
}
* 100) / (
${
avg_past3
}
)"
)
goal1_reached
=
$(
bc
-l
<<<
"
$month0_donated
>=
$avg_past3
"
)
goal2_target
=
$(
bc
-l
<<<
"scale=2;
$avg_past3
+
$spending_buffer
"
)
goal2_percentage
=
$(
bc
-l
<<<
"scale=2; ((
${
month0_donated
}
-
$avg_past3
) * 100) / (
$goal2_target
-
$avg_past3
)"
)
goal2_reached
=
$(
bc
-l
<<<
"
$month0_donated
>=
$goal2_target
"
)
goal3_target
=
$(
echo
"scale=2; (((
$month1_th
+
$month2_th
+
$month3_th
) / 3) * 60) +
$goal2_target
"
| bc
-l
)
goal3_percentage
=
$(
bc
-l
<<<
"scale=2; ((
${
month0_donated
}
-
$goal2_target
) * 100) / (
$goal3_target
-
$goal2_target
)"
)
goal3_reached
=
$(
bc
-l
<<<
"
$month0_donated
>=
$goal3_target
"
)
goals
=(
1 2 3
)
for
i
in
${
goals
[@]
}
;
do
percentage
=
goal
${
i
}
_percentage
reached
=
goal
${
i
}
_reached
if
((
"
${
!reached
}
"
==
1
))
;
then
declare
goal
${
i
}
_lenght
=
100
declare
goal
${
i
}
_bar
=
"linear-gradient(90deg, #0093f0 0%, #0093f0 100%)"
declare
goal
${
i
}
_success
=
"background: #0093f0;"
declare
goal
${
i
}
_noflash
=
"animation: none;"
else
declare
goal
${
i
}
_lenght
=
${
!percentage
}
lenght
=
goal
${
i
}
_lenght
declare
goal
${
i
}
_bar
=
"linear-gradient(90deg, #0093f0 0%, #0093f0
${
!lenght
}
%, rgba(0,0,0,0)
${
!lenght
}
%)"
fi
done
# little bit dirty – to avoid all hr's to get filled at the same time
if
[
$goal1_lenght
!=
100
]
;
then
goal2_bar
=
none
goal3_bar
=
none
elif
[
$goal2_lenght
!=
100
]
;
then
goal3_bar
=
none
fi
generated
=
$(
date
+
'%A, %d.%m.%Y – %H:%M%P %Z'
)
echo
" span.donate-goals-current>span {
display: none;
}
span.donate-goals-current::after {
content:
\"
${
month0_donated
}
\"
;
visibility: visible;
display: inline-block;
}
.donate-goals > .target .icon.progress-goal1 {
background-image:
$goal1_bar
;
background-color: #a1b3c4;
}
.donate-goals hr.progress-goal2 {
background-image:
$goal2_bar
;
}
.donate-goals hr.progress-goal3 {
background-image:
$goal3_bar
;
}
span.goal1::before {
content:
\"
$avg_past3
\"
;
}
span.goal2::before {
content:
\"
$goal2_target
\"
;
}
span.goal3::before {
content:
\"
$goal3_target
\"
;
}
.donate-goals > .target .icon.progress-goal1,
.progress-goal1+.tooltip+.target>.icon {
$goal1_success
$goal1_noflash
}
.progress-goal2+.target .icon,
.progress-goal2+.tooltip+.target>.icon {
$goal2_success
$goal2_noflash
}
.progress-goal3+.target .icon,
.progress-goal3+.tooltip+.target>.icon {
$goal3_success
$goal3_noflash
}
.donate-goals-generated::before {
content:
\"
${
generated
}
\"
;
} "
>
$outpath
/donate-goals.css
echo
"✅ goals css written."
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment