-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(logservice): Add possible data field to filter #68953
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
Conversation
organization_id: int | None, | ||
target_object_id: int | None, | ||
event: int | None, | ||
data: dict[str, str] | None, |
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.
data: dict[str, str] | None, | |
data: dict[str, str] | None = None, |
We can default data
to be None
so that we don't need to update the log_service.find_last_log()
calls to add the data
parameter in both sentry
and getsentry
.
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.
Yup. When changing parameters of hybrid cloud services, everything new must have default parameters due to fragmented deployment.
target_object=target_object_id, | ||
event=event, | ||
).last() | ||
if data: # Only use data field for fitlering if it isn't None |
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.
what about
last_entry_q: QuerySet[AuditLogEntry] = AuditLogEntry.objects.filter(
organization_id=organization_id,
target_object=target_object_id,
event=event,
)
if data:
last_entry_q = last_entry_q.filter(data=data)
last_entry: AuditLogEntry | None = last_entry_q.last()
organization_id: int | None, | ||
target_object_id: int | None, | ||
event: int | None, | ||
data: dict[str, str] | None, |
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.
data: dict[str, str] | None, | |
data: dict[str, str] | None = None, |
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.
With the additional default added, I haven't been able to figure out how to get the params to include the data
field when calling cls._get_abstract_rpc_methods()
here. Any ideas?
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.
You also need to change the signature of the abstract base class (LogService) to match. When the signatures don't match it isn't included.
@@ -38,6 +38,7 @@ def find_last_log( | |||
organization_id: int | None, | |||
target_object_id: int | None, | |||
event: int | None, | |||
data: dict[str, str] | None, |
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.
= None
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.
Looks good to me.
9aae3f6
to
d17cc32
Compare
Adds a possible
data
field tofind_last_log()
to enable filtering by that field if and only if it is included.