chore: code quality

This commit is contained in:
Vlad Stan
2024-11-25 14:53:56 +02:00
parent 366f89d5f1
commit 24335f4e64
3 changed files with 15 additions and 8 deletions

View File

@@ -36,6 +36,7 @@ class AuditFilters(FilterModel):
"path",
"request_method",
"response_code",
"component",
]
__sort_fields__ = [
"created_at",
@@ -47,6 +48,7 @@ class AuditFilters(FilterModel):
path: Optional[str] = None
request_method: Optional[str] = None
response_code: Optional[str] = None
component: Optional[str] = None
class AuditCountStat(BaseModel):

View File

@@ -156,7 +156,7 @@ class AuditMiddleware(BaseHTTPMiddleware):
):
try:
http_method = request.scope.get("method", None)
path = request.scope.get("path", None)
path: Optional[str] = getattr(request.scope.get("route", {}), "path", None)
response_code = str(response.status_code) if response else None
if not settings.audit_http_request(http_method, path, response_code):
return None
@@ -168,7 +168,6 @@ class AuditMiddleware(BaseHTTPMiddleware):
user_id = request.scope.get("user_id", None)
if settings.is_super_user(user_id):
user_id = "super_user"
path: Optional[str] = getattr(request.scope.get("route", {}), "path", None)
component = "core"
if path and not path.startswith("/api"):
component = path.split("/")[1]

View File

@@ -106,13 +106,13 @@ window.app = Vue.createApp({
methods: {
async fetchAudit(props) {
try {
console.log("### fetchAudit", this.searchData)
console.log('### fetchAudit', this.searchData)
const params = LNbits.utils.prepareFilterQuery(this.auditTable, props)
const {data} = await LNbits.api.request(
'GET',
`/audit/api/v1?${params}`
)
console.log("### data", data)
console.log('### data', data)
this.auditTable.pagination.rowsNumber = data.total
this.auditEntries = data.data
await this.fetchAuditStats(props)
@@ -132,7 +132,9 @@ window.app = Vue.createApp({
)
const request_methods = data.request_method.map(rm => rm.field)
this.searchOptions.request_method = request_methods
this.searchOptions.request_method = [
...new Set(this.searchOptions.request_method.concat(request_methods))
]
this.requestMethodChart.data.labels = request_methods
this.requestMethodChart.data.datasets[0].data = data.request_method.map(
rm => rm.total
@@ -140,7 +142,9 @@ window.app = Vue.createApp({
this.requestMethodChart.update()
const response_codes = data.response_code.map(rm => rm.field)
this.searchOptions.response_code = response_codes
this.searchOptions.response_code = [
...new Set(this.searchOptions.response_code.concat(response_codes))
]
this.responseCodeChart.data.labels = response_codes
this.responseCodeChart.data.datasets[0].data = data.response_code.map(
rm => rm.total
@@ -148,7 +152,9 @@ window.app = Vue.createApp({
this.responseCodeChart.update()
const components = data.component.map(rm => rm.field)
this.searchOptions.component = components
this.searchOptions.component = [
...new Set(this.searchOptions.component.concat(components))
]
this.componentUseChart.data.labels = components
this.componentUseChart.data.datasets[0].data = data.component.map(
rm => rm.total
@@ -249,7 +255,7 @@ window.app = Vue.createApp({
maintainAspectRatio: false,
plugins: {
title: {
display: false,
display: false
}
}
},