Skip to content

Commit

Permalink
[fix] Show only running instances (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Sep 2, 2024
1 parent f7c44bf commit 76a86e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
9 changes: 7 additions & 2 deletions fixbackend/inventory/inventory_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,11 @@ async def compute_inventory_info(duration: timedelta) -> InventorySummary:
}

async def progress(
metric: str, not_exist: int, group: Optional[Set[str]] = None, aggregation: Optional[str] = None
metric: str,
not_exist: int,
group: Optional[Set[str]] = None,
aggregation: Optional[str] = None,
filter_group: Optional[List[str]] = None,
) -> Tuple[int, int]:
async with self.client.timeseries(
dba,
Expand All @@ -759,6 +763,7 @@ async def progress(
end=now,
granularity=duration,
group=group,
filter_group=filter_group,
aggregation=aggregation,
) as response:
entries = [int(r["v"]) async for r in response]
Expand Down Expand Up @@ -819,7 +824,7 @@ async def overall_score() -> Tuple[int, int]:
resources_per_account_timeline(),
overall_score(),
nr_of_changes(),
progress("instances_total", 0, group=set(), aggregation="sum"),
progress("instances_total", 0, group=set(), aggregation="sum", filter_group=["status==running"]),
progress("cores_total", 0, group=set(), aggregation="sum"),
progress("memory_bytes", 0, group=set(), aggregation="sum"),
progress("volumes_total", 0, group=set(), aggregation="sum"),
Expand Down
19 changes: 15 additions & 4 deletions fixbackend/notification/email/status_update_email_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import asyncio
from datetime import timedelta, datetime
from typing import Optional, Tuple, Set, Dict, cast, Any, Callable
from typing import Optional, Tuple, Set, Dict, cast, Any, Callable, List

import plotly.graph_objects as go
from fixcloudutils.asyncio.process_pool import AsyncProcessPool
Expand Down Expand Up @@ -124,10 +124,21 @@ async def _create_messages_dict(
}

async def progress(
metric: str, not_exist: int, group: Optional[Set[str]] = None, aggregation: Optional[str] = None
metric: str,
not_exist: int,
group: Optional[Set[str]] = None,
aggregation: Optional[str] = None,
filter_group: Optional[List[str]] = None,
) -> Tuple[int, int]:
async with self.inventory_service.client.timeseries(
dba, metric, start=now - duration, end=now, granularity=duration, group=group, aggregation=aggregation
dba,
metric,
start=now - duration,
end=now,
granularity=duration,
group=group,
filter_group=filter_group,
aggregation=aggregation,
) as response:
entries = [int(r["v"]) async for r in response]
if len(entries) == 0: # timeseries haven't been created yet
Expand Down Expand Up @@ -190,7 +201,7 @@ async def overall_score() -> Tuple[bytes, Tuple[int, int]]:
resources_per_account_timeline(),
overall_score(),
nr_of_changes(),
progress("instances_total", 0, group=set(), aggregation="sum"),
progress("instances_total", 0, group=set(), aggregation="sum", filter_group=["status==running"]),
progress("cores_total", 0, group=set(), aggregation="sum"),
progress("memory_bytes", 0, group=set(), aggregation="sum"),
progress("volumes_total", 0, group=set(), aggregation="sum"),
Expand Down

0 comments on commit 76a86e9

Please sign in to comment.