-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ [#33] Add reset_db_save_after option to config model #37
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
da5ac00
:sparkles: [#33] Add reset_db_save_after option to config model
stevenbal 4fc3883
:white_check_mark: [#33] Add/fix tests for db configurable reset_db_s…
stevenbal bb72e56
:memo: [#33] Update docs
stevenbal 2220b2d
:ok_hand: [#33] PR feedback
stevenbal 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
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
log_outgoing_requests/migrations/0006_outgoingrequestslogconfig_reset_db_save_after.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.2.23 on 2024-02-19 11:12 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("log_outgoing_requests", "0005_alter_outgoingrequestslog_url"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="outgoingrequestslogconfig", | ||
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.", | ||
null=True, | ||
verbose_name="Reset saving logs in database after", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,13 +206,23 @@ class OutgoingRequestsLogConfig(SingletonModel): | |
"If 'Require content length' is not checked, this setting has no effect." | ||
), | ||
) | ||
reset_db_save_after = models.PositiveIntegerField( | ||
_("Reset saving logs in database after"), | ||
null=True, | ||
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." | ||
), | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also add a min value validator to set at least 1 minute, 0 minutes would immediately reset it and makes it unclear in the code if the value is set to Adding the validator removes ambiguity |
||
|
||
class Meta: | ||
verbose_name = _("Outgoing request log configuration") | ||
|
||
def save(self, *args, **kwargs): | ||
super().save(*args, **kwargs) | ||
schedule_config_reset() | ||
schedule_config_reset(self) | ||
|
||
@property | ||
def save_logs_enabled(self): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how I can add the
OutgoingRequestsLogConfig
typehint here without the docs check failing, I tried it withif TYPE_CHECKING
but that didn't workThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from __future__ import annotations
and then a conditional import tends to work usually, but instead, why not pass theself.reset_db_save_after
so you can provide a typehintreset_after: int | None
so you're only working in primitives :)