fix: fixes a UI bug showing an incorrect number of exceptions
This commit is contained in:
parent
b760c7a2a6
commit
db371ac8c0
2 changed files with 24 additions and 4 deletions
|
|
@ -36,14 +36,29 @@ class ExceptionsTrackerView(BaseAppView):
|
|||
c.navlist = navigation_list(self.request)
|
||||
return c
|
||||
|
||||
def count_all_exceptions(self):
|
||||
def count_all_exceptions(self, type_filter: str = None) -> int:
|
||||
exc_store_path = exc_tracking.get_exc_store()
|
||||
count = 0
|
||||
for fname in os.listdir(exc_store_path):
|
||||
parts = fname.split("_", 2)
|
||||
if not len(parts) == 3:
|
||||
continue
|
||||
count += 1
|
||||
|
||||
if type_filter is not None:
|
||||
# count only filtered exceptions
|
||||
full_path = os.path.join(exc_store_path, fname)
|
||||
if not os.path.isfile(full_path):
|
||||
continue
|
||||
try:
|
||||
with open(full_path, "rb") as f:
|
||||
exc_metadata = exc_tracking.exc_unserialize(f.read())
|
||||
exception_type = exc_metadata.get("exc_type")
|
||||
if exception_type == type_filter:
|
||||
count += 1
|
||||
except Exception:
|
||||
log.exception(f"Failed to read exc data from:{full_path}")
|
||||
else:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def get_all_exceptions(self, read_metadata=False, limit=None, type_filter=None):
|
||||
|
|
@ -107,7 +122,7 @@ class ExceptionsTrackerView(BaseAppView):
|
|||
c.type_filter = self.request.GET.get("type_filter")
|
||||
c.next_limit = c.limit + 50
|
||||
c.exception_list = self.get_all_exceptions(read_metadata=True, limit=c.limit, type_filter=c.type_filter)
|
||||
c.exception_list_count = self.count_all_exceptions()
|
||||
c.exception_list_count = self.count_all_exceptions(type_filter=c.type_filter)
|
||||
c.exception_store_dir = exc_tracking.get_exc_store()
|
||||
return self._get_template_context(c)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,12 @@
|
|||
<input type="hidden" name="type_filter", value="${c.type_filter}">
|
||||
<div class="field">
|
||||
<button class="btn btn-small btn-danger" type="submit"
|
||||
onclick="submitConfirm(event, this, _gettext('Confirm to delete all exceptions'), _gettext('Delete'), '${'total:{}'.format(c.exception_list_count)}')"
|
||||
onclick="submitConfirm(
|
||||
event,
|
||||
this,
|
||||
_gettext('${'Delete all `{}` exceptions'.format(c.type_filter) if c.type_filter else 'Confirm to delete all exceptions'}'),
|
||||
_gettext('Delete'),
|
||||
'${'total:{}'.format(c.exception_list_count)}')"
|
||||
>
|
||||
<i class="icon-remove"></i>
|
||||
% if c.type_filter:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue