Skip to content

Commit 462e869

Browse files
committed
v1.0.3
1 parent ce6739c commit 462e869

4 files changed

Lines changed: 6 additions & 26 deletions

File tree

django_gc/services/global_config_service.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,13 @@ def refresh_value(self, key: str | StrEnum) -> None:
8383
cache_key = self.build_cache_key(key=key)
8484
try:
8585
self._cache.delete(key=cache_key)
86-
config = (
87-
GlobalConfig.objects.only('key', 'value', 'value_type', 'nullable')
88-
.filter(pk=str(key))
89-
.first()
90-
)
86+
config = GlobalConfig.objects.only('key', 'value', 'value_type', 'nullable').filter(pk=str(key)).first()
9187
if config is None:
9288
raise GlobalConfigNotFoundError(key=str(key))
9389
self._cache.set_many_if_lock_owned(
9490
values={
9591
cache_key: GlobalConfigCacheValueDTO(
96-
value=self._parse_value(config=config),
97-
value_type=SettingType(config.value_type),
92+
value=self._parse_value(config=config), value_type=SettingType(config.value_type)
9893
)
9994
},
10095
lock=lock,

django_gc/signals/callbacks.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ def refresh_global_config_value_safely(changed_key: str | StrEnum) -> None:
1414
GlobalConfigService().refresh_value(key=changed_key)
1515
except Exception as e:
1616
logger.exception(
17-
{
18-
'message': 'Failed to refresh changed GlobalConfig value after commit.',
19-
'data': {'error': str(e)},
20-
}
17+
{'message': 'Failed to refresh changed GlobalConfig value after commit.', 'data': {'error': str(e)}}
2118
)
2219

2320

django_gc/signals/refresh_global_configs_cache.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,11 @@
1212

1313
@receiver(signal=post_save, sender=GlobalConfig, dispatch_uid='django_gc.refresh_cache')
1414
def refresh_global_configs_cache(
15-
sender: type[GlobalConfig],
16-
instance: GlobalConfig,
17-
using: str,
18-
raw: bool,
19-
**kwargs: Any,
15+
sender: type[GlobalConfig], instance: GlobalConfig, using: str, raw: bool, **kwargs: Any
2016
) -> None:
2117
"""
2218
Запланировать точечное обновление изменённого ключа после commit.
2319
"""
2420
if raw or is_refresh_suppressed():
2521
return
26-
transaction.on_commit(
27-
partial(refresh_global_config_value_safely, changed_key=str(instance.key)),
28-
using=using,
29-
)
22+
transaction.on_commit(partial(refresh_global_config_value_safely, changed_key=str(instance.key)), using=using)

tests/test_global_config_signals.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ def test_fixture_load_does_not_refresh_cache(self) -> None:
4444
"""
4545
config = GlobalConfig.objects.get(pk='platform-pagination-size')
4646
with self.captureOnCommitCallbacks() as callbacks:
47-
refresh_global_configs_cache(
48-
sender=GlobalConfig,
49-
instance=config,
50-
using='default',
51-
raw=True,
52-
)
47+
refresh_global_configs_cache(sender=GlobalConfig, instance=config, using='default', raw=True)
5348

5449
self.assertEqual(callbacks, [])
5550

0 commit comments

Comments
 (0)