Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2a031df
Quick draft of auto-cleaning functionality
Archmonger Jan 31, 2024
f8b99fc
remove auto_clean from config name
Archmonger Feb 1, 2024
685db22
Add type hinting to _cached_static_contents function
Archmonger Feb 1, 2024
eba80d3
ignore_config
Archmonger Feb 1, 2024
2e089de
docs cleanup
Archmonger Feb 1, 2024
4ea41f5
CLEAN_NEEDED_BY caching
Archmonger Feb 1, 2024
836d719
fix link
Archmonger Feb 1, 2024
dbf7e12
fix tests
Archmonger Feb 1, 2024
e1bd185
minor docs wordsmithing
Archmonger Feb 1, 2024
e2c088f
Merge remote-tracking branch 'upstream/main' into robust-cleanup-config
Archmonger Feb 1, 2024
43685b8
Add management command
Archmonger Feb 1, 2024
6c1ecf0
add changelog entries
Archmonger Feb 1, 2024
ef90460
Add checks for new config values
Archmonger Feb 1, 2024
5a57807
better interface for management command
Archmonger Feb 1, 2024
75670a8
ignore settings.py attributes for management command calls
Archmonger Feb 2, 2024
3594cee
add a check for common misspelling
Archmonger Feb 2, 2024
da855dd
Add comment for a bugfix
Archmonger Feb 2, 2024
107b64c
Auto-Clean Settings docs
Archmonger Feb 2, 2024
c6b8e13
fix a few stale docs lines
Archmonger Feb 2, 2024
43ee1ac
remove dead LOC
Archmonger Feb 2, 2024
2799ed0
Django Query Postprocessor docs cleanup
Archmonger Feb 2, 2024
e8fe1da
allow REACTPY_CLEAN_INTERVAL to be None
Archmonger Feb 2, 2024
08e1025
prepare for management command docs
Archmonger Feb 3, 2024
32ceea6
management command docs
Archmonger Feb 3, 2024
3385887
minor docs styling change
Archmonger Feb 3, 2024
e0c771d
avoid django timezone module
Archmonger Feb 3, 2024
05554dc
fix tests
Archmonger Feb 3, 2024
ad62a68
fix tests in a different way
Archmonger Feb 3, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove auto_clean from config name
  • Loading branch information
Archmonger committed Feb 1, 2024
commit f8b99fc1b542872459b430f3f514c06bcff92d11
8 changes: 4 additions & 4 deletions src/reactpy_django/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

def clean_all(immediate: bool = False, manual_clean=True):
from reactpy_django.config import (
REACTPY_AUTO_CLEAN_SESSIONS,
REACTPY_AUTO_CLEAN_USER_DATA,
REACTPY_CLEAN_SESSIONS,
REACTPY_CLEAN_USER_DATA,
)
from reactpy_django.models import Config

config = Config.load()
if immediate or is_clean_needed(config):
if manual_clean or REACTPY_AUTO_CLEAN_SESSIONS:
if manual_clean or REACTPY_CLEAN_SESSIONS:
clean_sessions()
if manual_clean or REACTPY_AUTO_CLEAN_USER_DATA:
if manual_clean or REACTPY_CLEAN_USER_DATA:
clean_user_data()
config.cleaned_at = timezone.now()
config.save()
Expand Down
12 changes: 6 additions & 6 deletions src/reactpy_django/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@
"REACTPY_AUTO_RELOGIN",
False,
)
REACTPY_AUTO_CLEAN_INTERVAL: int = getattr(
REACTPY_CLEAN_INTERVAL: int = getattr(
settings,
"REACTPY_AUTO_CLEAN_INTERVAL",
"REACTPY_CLEAN_INTERVAL",
604800, # Default to 7 days
)
REACTPY_AUTO_CLEAN_SESSIONS: bool = getattr(
REACTPY_CLEAN_SESSIONS: bool = getattr(
settings,
"REACTPY_AUTO_CLEAN_SESSIONS",
"REACTPY_CLEAN_SESSIONS",
True,
)
REACTPY_AUTO_CLEAN_USER_DATA: bool = getattr(
REACTPY_CLEAN_USER_DATA: bool = getattr(
settings,
"REACTPY_AUTO_CLEAN_USER_DATA",
"REACTPY_CLEAN_USER_DATA",
True,
)
4 changes: 2 additions & 2 deletions src/reactpy_django/websocket/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async def connect(self) -> None:

async def disconnect(self, code: int) -> None:
"""The browser has disconnected."""
from reactpy_django.config import REACTPY_AUTO_CLEAN_INTERVAL
from reactpy_django.config import REACTPY_CLEAN_INTERVAL

self.dispatcher.cancel()

Expand All @@ -112,7 +112,7 @@ async def disconnect(self, code: int) -> None:
)

# Queue a cleanup, if needed
if REACTPY_AUTO_CLEAN_INTERVAL > -1:
if REACTPY_CLEAN_INTERVAL > -1:
try:
await database_sync_to_async(clean_all)()
except Exception:
Expand Down