-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add a task_name property to DBTaskResult #127
Add a task_name property to DBTaskResult #127
Conversation
87caa7c
to
e519d84
Compare
@property | ||
def task_name(self) -> str: | ||
try: | ||
return self.task_path.rsplit(".", 1)[1] |
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.
Thought: It'd be nice to keep using task.name
by default, but falling back to these 2 if it's not available.
e519d84
to
17a6dd3
Compare
Updated - and improved the tests a little bit this time round. |
tests/tests/test_database_backend.py
Outdated
def test_task_name(self) -> None: | ||
db_task_result = DBTaskResult.objects.create( | ||
args_kwargs={"args": [], "kwargs": {}}, | ||
task_path="tests.tasks.noop_task", |
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.
Suggestion: Given these tests are incredibly similar, it'd be better to use subTest
to just add cases and expected values.
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.
Updated in a965773
If a task still exists - use that for the name. However if the underlying function no longer exists - use task_path to come up with an appropriate name to show in the admin.
17a6dd3
to
a965773
Compare
Closes #126
Added a fairly simple method/property to
DBTaskResult
to return the task name based on the saved path in the database.This does change the name of the column in the admin from "Task" to "Task name" - let me know if that's an issue at all.