Skip to content

Commit f914f63

Browse files
authored
Fix sql, singleton and additional widgets (#308)
1 parent cc018f9 commit f914f63

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/daf/logging/sql/mgr.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,11 @@ async def analytic_get_num_invites(
10991099
return await self.__analytic_get_counts(
11001100
session,
11011101
group_by,
1102-
[InviteLOG.invite_id],
1102+
[
1103+
Invite.discord_id,
1104+
GuildUSER.snowflake_id,
1105+
GuildUSER.name,
1106+
],
11031107
conditions,
11041108
limit,
11051109
sort_by,

src/daf_gui/widgets/convert.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Any, Union, List, get_type_hints
66
from contextlib import suppress
77
from enum import Enum
8+
from inspect import signature
89

910
import decimal
1011
import datetime as dt
@@ -233,13 +234,20 @@ def convert_to_object_info(object_: object, save_original = False, cache = False
233234
"""
234235
def _convert_object_info(object_, save_original, object_type, attrs):
235236
data_conv = {}
236-
237237
for k, v in attrs.items():
238238
with suppress(Exception):
239239
if callable(v):
240240
value = v(object_)
241241
else:
242242
value = getattr(object_, v)
243+
244+
# Check if object is a singleton that is not builtin.
245+
# Singletons should not be stored as they would get recreated causing issues on save -> load.
246+
type_value = type(value)
247+
with suppress(ValueError): # Some don't have a signature
248+
if type_value.__name__ not in __builtins__ and not len(signature(type_value).parameters):
249+
continue
250+
243251
if value is object_:
244252
data_conv[k] = value
245253
else:

src/daf_gui/widgets/extra.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ def _callback(*args):
144144
continue
145145

146146
if hasattr(item, "update"):
147-
ADDITIONAL_WIDGETS[item] = [
147+
if item not in ADDITIONAL_WIDGETS:
148+
ADDITIONAL_WIDGETS[item] = []
149+
ADDITIONAL_WIDGETS[item].extend([
148150
AdditionalWidget(ttk.Button, setup_additional_live_update, text="Live update"),
149151
AdditionalWidget(ttk.Button, setup_additional_live_refresh, text="Refresh")
150-
]
152+
])
151153

152154

153155
__all__ = list(globals().keys())

0 commit comments

Comments
 (0)