Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Show only running instances #606

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading