(
self,
limit: int = 8,
action: Optional[str] = None,
target_type: Optional[str] = None,
keyword: Optional[str] = None,
)
| 749 | } |
| 750 | |
| 751 | async def list_admin_activities( |
| 752 | self, |
| 753 | limit: int = 8, |
| 754 | action: Optional[str] = None, |
| 755 | target_type: Optional[str] = None, |
| 756 | keyword: Optional[str] = None, |
| 757 | ) -> dict[str, Any]: |
| 758 | try: |
| 759 | normalized_limit = int(limit or 8) |
| 760 | except (TypeError, ValueError): |
| 761 | normalized_limit = 8 |
| 762 | limit = min(max(normalized_limit, 1), self.MAX_ADMIN_ACTIVITIES) |
| 763 | activities = await self._get_admin_activities() |
| 764 | normalized_action = self._normalize_admin_activity_text(action).lower() |
| 765 | normalized_target_type = self._normalize_admin_activity_text(target_type).lower() |
| 766 | normalized_keyword = self._normalize_admin_activity_text(keyword).lower() |
| 767 | filtered_activities = self._filter_admin_activities( |
| 768 | activities, |
| 769 | action=normalized_action, |
| 770 | target_type=normalized_target_type, |
| 771 | keyword=normalized_keyword, |
| 772 | ) |
| 773 | visible_activities = filtered_activities[:limit] |
| 774 | action_options = self._build_admin_activity_options(activities, "action") |
| 775 | target_type_options = self._build_admin_activity_options(activities, "targetType") |
| 776 | return { |
| 777 | "activities": visible_activities, |
| 778 | "items": visible_activities, |
| 779 | "total": len(filtered_activities), |
| 780 | "storedTotal": len(activities), |
| 781 | "stored_total": len(activities), |
| 782 | "limit": limit, |
| 783 | "filters": { |
| 784 | "action": normalized_action, |
| 785 | "targetType": normalized_target_type, |
| 786 | "target_type": normalized_target_type, |
| 787 | "keyword": normalized_keyword, |
| 788 | }, |
| 789 | "actionOptions": action_options, |
| 790 | "action_options": action_options, |
| 791 | "targetTypeOptions": target_type_options, |
| 792 | "target_type_options": target_type_options, |
| 793 | } |
| 794 | |
| 795 | async def record_admin_activity( |
| 796 | self, |
no test coverage detected