Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
- crash in connections when active records have a "duration" field
- inconsistency in the org list with the selected org
  • Loading branch information
spyder-griffith committed Aug 15, 2022
1 parent aa89033 commit a72b6cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
6 changes: 4 additions & 2 deletions spydertop/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,13 @@ def format_environ(_m, _pr, _r, p):
(
"DURATION",
lambda m, c: pretty_time(m.timestamp - c["valid_from"])
if "duration" not in c or c["valid_to"] > m.timestamp
if "duration" not in c or "valid_to" not in c or c["valid_to"] > m.timestamp
else pretty_time(c["duration"]),
"<",
9,
lambda m, c: c.get("duration", m.timestamp - c["valid_from"]),
lambda m, c: m.timestamp - c["valid_from"]
if "duration" not in c or "valid_to" not in c or c["valid_to"] > m.timestamp
else c["duration"],
True,
),
(
Expand Down
16 changes: 7 additions & 9 deletions spydertop/screens/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,22 +252,20 @@ def load_orgs():
if len(self.cache["orgs"]) == 1:
self.set_org(self.cache["orgs"][0])
if len(self.cache["orgs"]) > 1:
orgs = sorted(
self.cache["orgs"],
key=lambda o: o.get("total_sources", 0),
reverse=True,
)

if self.config.org is None:
index = 0
else:
try:
index = [o["uid"] for o in self.cache["orgs"]].index(
self.config.org
)
index = [o["uid"] for o in orgs].index(self.config.org)
except ValueError:
index = 0

orgs = sorted(
self.cache["orgs"],
key=lambda o: o.get("total_sources", 0),
reverse=True,
)

self.build_question(
"Please select an organization",
[
Expand Down
3 changes: 1 addition & 2 deletions spydertop/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def pretty_time(time: float) -> str:
return f"{microseconds}μs"
return f"{milliseconds}ms"
return f"{minutes}:{seconds:02d}.{centiseconds:02d}"
else:
return f"${{6}}{hours}h${{7}}{minutes:02d}:{seconds:02d}"
return f"${{6}}{hours}h${{7}}{minutes:02d}:{seconds:02d}"


def pretty_datetime(d_time: datetime) -> str:
Expand Down

0 comments on commit a72b6cf

Please sign in to comment.