Add alternate set of mock reporting data
This commit is contained in:
parent
0677a1b4dd
commit
4982b80d9b
@ -1,7 +1,7 @@
|
|||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
|
||||||
|
|
||||||
MONTHLY_SPEND = {
|
MONTHLY_SPEND_AARDVARK = {
|
||||||
"LC04": {
|
"LC04": {
|
||||||
"Integ": {
|
"Integ": {
|
||||||
"10/2018": 284,
|
"10/2018": 284,
|
||||||
@ -116,24 +116,52 @@ MONTHLY_SPEND = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MONTHLY_SPEND_BELUGA = {
|
||||||
|
"NP02": {
|
||||||
|
"Integ": {
|
||||||
|
"02/2019": 284,
|
||||||
|
"03/2019": 1210,
|
||||||
|
},
|
||||||
|
"PreProd": {
|
||||||
|
"02/2019": 812,
|
||||||
|
"03/2019": 1389,
|
||||||
|
},
|
||||||
|
"Prod": {
|
||||||
|
"02/2019": 3742,
|
||||||
|
"03/2019": 4716,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"FM": {
|
||||||
|
"Integ": {
|
||||||
|
"03/2019": 1498,
|
||||||
|
},
|
||||||
|
"Prod": {
|
||||||
|
"03/2019": 5686,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Reports:
|
class Reports:
|
||||||
@classmethod
|
@classmethod
|
||||||
def workspace_totals(cls, workspace):
|
def workspace_totals(cls, alternate):
|
||||||
|
data = MONTHLY_SPEND_BELUGA if alternate else MONTHLY_SPEND_AARDVARK
|
||||||
spent = sum(
|
spent = sum(
|
||||||
[
|
[
|
||||||
spend
|
spend
|
||||||
for project in MONTHLY_SPEND.values()
|
for project in data.values()
|
||||||
for env in project.values()
|
for env in project.values()
|
||||||
for spend in env.values()
|
for spend in env.values()
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return {"budget": 500_000, "spent": spent}
|
budget = 70_000 if alternate else 500_000
|
||||||
|
return {"budget": budget, "spent": spent}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def monthly_totals(cls, workspace):
|
def monthly_totals(cls, alternate):
|
||||||
|
data = MONTHLY_SPEND_BELUGA if alternate else MONTHLY_SPEND_AARDVARK
|
||||||
project_totals = {}
|
project_totals = {}
|
||||||
for project, environments in MONTHLY_SPEND.items():
|
for project, environments in data.items():
|
||||||
project_spend = [
|
project_spend = [
|
||||||
(month, spend)
|
(month, spend)
|
||||||
for env in environments.values()
|
for env in environments.values()
|
||||||
@ -154,7 +182,7 @@ class Reports:
|
|||||||
workspace_totals[month] = sum([spend[1] for spend in spends])
|
workspace_totals[month] = sum([spend[1] for spend in spends])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"environments": MONTHLY_SPEND,
|
"environments": data,
|
||||||
"projects": project_totals,
|
"projects": project_totals,
|
||||||
"workspace": workspace_totals,
|
"workspace": workspace_totals,
|
||||||
}
|
}
|
||||||
|
@ -89,36 +89,37 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% set current_month = '03/2019' %}
|
||||||
|
{% set prev_month = '02/2019' %}
|
||||||
|
{% set two_months_ago = '01/2019' %}
|
||||||
|
{% set workspace_totals = monthly_totals['workspace'] %}
|
||||||
|
|
||||||
<div class='spend-table responsive-table-wrapper'>
|
<div class='spend-table responsive-table-wrapper'>
|
||||||
<div class='spend-table__header'>
|
<div class='spend-table__header'>
|
||||||
<h2 class='spend-table__title'>Total spend per month</h2>
|
<h2 class='spend-table__title'>Total spend per month</h2>
|
||||||
|
|
||||||
<select name='month' id='month' class='spend-table__month-select'>
|
<select name='month' id='month' class='spend-table__month-select'>
|
||||||
<option value='05/2019'>May 2019</option>
|
<option value='03/2019'>March 2019</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<th scope='col'><span class='usa-sr-only'>Spending scope</span></th>
|
<th scope='col'><span class='usa-sr-only'>Spending scope</span></th>
|
||||||
<th scope='col' class='table-cell--align-right previous-month'>March 2019</th>
|
<th scope='col' class='table-cell--align-right previous-month'>January 2019</th>
|
||||||
<th scope='col' class='table-cell--align-right previous-month'>April 2019</th>
|
<th scope='col' class='table-cell--align-right previous-month'>February 2019</th>
|
||||||
<th scope='col' class='table-cell--align-right current-month'>May 2019</th>
|
<th scope='col' class='table-cell--align-right current-month'>March 2019</th>
|
||||||
<td class='current-month'></td>
|
<td class='current-month'></td>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
{% set workspace_totals = monthly_totals['workspace'] %}
|
|
||||||
{% set current_month = '05/2019' %}
|
|
||||||
{% set prev_month = '04/2019' %}
|
|
||||||
{% set two_months_ago = '03/2019' %}
|
|
||||||
<tbody class='spend-table__workspace'>
|
<tbody class='spend-table__workspace'>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope='row'>Workspace Total</th>
|
<th scope='row'>Workspace Total</th>
|
||||||
<td class='table-cell--align-right previous-month'>{{ workspace_totals[two_months_ago] | dollars }}</td>
|
<td class='table-cell--align-right previous-month'>{{ workspace_totals.get(two_months_ago, 0) | dollars }}</td>
|
||||||
<td class='table-cell--align-right previous-month'>{{ workspace_totals[prev_month] | dollars }}</td>
|
<td class='table-cell--align-right previous-month'>{{ workspace_totals.get(prev_month, 0) | dollars }}</td>
|
||||||
<td class='table-cell--align-right current-month'>{{ workspace_totals[current_month] | dollars }}</td>
|
<td class='table-cell--align-right current-month'>{{ workspace_totals.get(current_month, 0) | dollars }}</td>
|
||||||
<td class='table-cell--expand current-month meter-cell'>
|
<td class='table-cell--expand current-month meter-cell'>
|
||||||
<meter value='{{ workspace_totals[current_month] }}' min='0' max='{{ workspace_totals[current_month] }}'></meter>
|
<meter value='{{ workspace_totals.get(current_month, 0) }}' min='0' max='{{ workspace_totals.get(current_month, 0) }}'></meter>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -138,8 +139,8 @@
|
|||||||
<td class='table-cell--align-right previous-month'>{{ project_totals.get(prev_month, 0) | dollars }}</td>
|
<td class='table-cell--align-right previous-month'>{{ project_totals.get(prev_month, 0) | dollars }}</td>
|
||||||
<td class='table-cell--align-right current-month'>{{ project_totals.get(current_month, 0) | dollars }}</td>
|
<td class='table-cell--align-right current-month'>{{ project_totals.get(current_month, 0) | dollars }}</td>
|
||||||
<td class='table-cell--expand current-month meter-cell'>
|
<td class='table-cell--expand current-month meter-cell'>
|
||||||
<span class='spend-table__meter-value'>{{ (100 * (project_totals.get(current_month) / workspace_totals[current_month])) | round | int }}%</span>
|
<span class='spend-table__meter-value'>{{ (100 * (project_totals.get(current_month, 0) / workspace_totals.get(current_month, 1))) | round | int }}%</span>
|
||||||
<meter value='{{ project_totals[current_month] }}' min='0' max='{{ workspace_totals[current_month] }}'></meter>
|
<meter value='{{ project_totals.get(current_month, 0) }}' min='0' max='{{ workspace_totals.get(current_month, 0) }}'></meter>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user