Skip to content

Commit

Permalink
👌 [#33] PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Feb 27, 2024
1 parent bb72e56 commit 8f26f5b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 2 additions & 4 deletions log_outgoing_requests/config_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
from .tasks import reset_config


def schedule_config_reset(config):
reset_after = (
config.reset_db_save_after or settings.LOG_OUTGOING_REQUESTS_RESET_DB_SAVE_AFTER
)
def schedule_config_reset(reset_after: int | None):
reset_after = reset_after or settings.LOG_OUTGOING_REQUESTS_RESET_DB_SAVE_AFTER
if not reset_after:
return

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by Django 3.2.23 on 2024-02-19 11:12
# Generated by Django 3.2.24 on 2024-02-27 09:32

import django.core.validators
from django.db import migrations, models


Expand All @@ -15,8 +16,9 @@ class Migration(migrations.Migration):
name="reset_db_save_after",
field=models.PositiveIntegerField(
blank=True,
help_text="If configured, after the config has been updated, reset the database logging after the specified number of minutes. Note: this overrides the LOG_OUTGOING_REQUESTS_RESET_DB_SAVE_AFTER environment variable.",
help_text="If configured, after the config has been updated, reset the database logging after the specified number of minutes. Note: this overrides the LOG_OUTGOING_REQUESTS_RESET_DB_SAVE_AFTER environment variable. Additionally, depending on the broker that is used, if this value is duration is too long the key for the reset task might have expired before that time. So make sure not to set too large a value for the reset.",
null=True,
validators=[django.core.validators.MinValueValidator(1)],
verbose_name="Reset saving logs in database after",
),
),
Expand Down
8 changes: 6 additions & 2 deletions log_outgoing_requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,14 @@ class OutgoingRequestsLogConfig(SingletonModel):
_("Reset saving logs in database after"),
null=True,
blank=True,
validators=[MinValueValidator(1)],
help_text=_(
"If configured, after the config has been updated, reset the database logging "
"after the specified number of minutes. Note: this overrides the "
"LOG_OUTGOING_REQUESTS_RESET_DB_SAVE_AFTER environment variable."
"LOG_OUTGOING_REQUESTS_RESET_DB_SAVE_AFTER environment variable. Additionally, "
"depending on the broker that is used, if this value is duration is too long "
"the key for the reset task might have expired before that time. So make sure not to "
"set too large a value for the reset."
),
)

Expand All @@ -222,7 +226,7 @@ class Meta:

def save(self, *args, **kwargs):
super().save(*args, **kwargs)
schedule_config_reset(self)
schedule_config_reset(self.reset_db_save_after)

@property
def save_logs_enabled(self):
Expand Down

0 comments on commit 8f26f5b

Please sign in to comment.