|
12 | 12 | slack_endpoint = os.environ['SLACK_ENDPOINT'] |
13 | 13 | slack_channel = os.environ['SLACK_CHANNEL'] |
14 | 14 |
|
15 | | -def getDiffrenceInPercent(current, previous, period): |
| 15 | +def getDiffrenceInPercent(current, previous, periodArg): |
16 | 16 | dif = round((current - previous) / previous * 100, 2) |
17 | | - period = "week" if (period == 7) else "month" |
18 | | - result = f"Up *{dif}%* over last {period}" if (dif > 0.0) else f"Down *{-dif}%* over last {period}" |
| 17 | + periodArg = "week" if (periodArg == 7) else "month" |
| 18 | + result = f"Up *{dif}%* over last {periodArg}" if (dif > 0.0) else f"Down *{-dif}%* over last {periodArg}" |
19 | 19 | return result |
20 | 20 |
|
21 | 21 | def getCostAndUsage(previous, period): |
@@ -51,10 +51,10 @@ def getCostAndUsage(previous, period): |
51 | 51 |
|
52 | 52 | return round(float(cost['ResultsByTime'][0]['Total']['UnblendedCost']['Amount']), 2) |
53 | 53 |
|
54 | | -def createPayload(period, slackChannel, currentCost, previousCost): |
55 | | - period = "week" if (period == 7) else "month" |
| 54 | +def createPayload(periodArg, slackChannel, currentCost, previousCost): |
| 55 | + periodArg = "week" if (periodArg == 7) else "month" |
56 | 56 |
|
57 | | - value = f"Total cost over this {period} - *${currentCost}*\nTotal cost over last {period} - *${previousCost}*\n{getDiffrenceInPercent(currentCost, previousCost, period)}" |
| 57 | + value = f"Total cost over this {periodArg} - *${currentCost}*\nTotal cost over last {periodArg} - *${previousCost}*\n{getDiffrenceInPercent(currentCost, previousCost, period)}" |
58 | 58 |
|
59 | 59 | payload = { |
60 | 60 | "channel": slackChannel, |
|
0 commit comments