fix: Remove dead code and unused fields - proper fixes per PROMPT.md
- large_org_optimizer.rs: Remove unused fields (cached_at, roles, organization_id from structs) Add partition_manager() getter to use the field - middleware.rs: Implement Display for AuthError to use InvalidToken message - organization_rbac.rs: Remove unused user_groups and user_direct_permissions fields - passkey.rs: Remove unused first_attempt_at field - opencv.rs: Remove unused format field and ImageFormat enum - rekognition.rs: Remove unused liveness_sessions field No #[allow(dead_code)] - code is properly fixed or deleted
This commit is contained in:
parent
c59d456e25
commit
703497b00c
6 changed files with 25 additions and 53 deletions
|
|
@ -486,7 +486,6 @@ impl OpenCvFaceDetector {
|
||||||
return Ok(ImageInfo {
|
return Ok(ImageInfo {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
format: ImageFormat::Png,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -495,7 +494,6 @@ impl OpenCvFaceDetector {
|
||||||
return Ok(ImageInfo {
|
return Ok(ImageInfo {
|
||||||
width: 640,
|
width: 640,
|
||||||
height: 480,
|
height: 480,
|
||||||
format: ImageFormat::Jpeg,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -517,7 +515,6 @@ impl OpenCvFaceDetector {
|
||||||
return Ok(ImageInfo {
|
return Ok(ImageInfo {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
format: ImageFormat::Bmp,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -525,7 +522,6 @@ impl OpenCvFaceDetector {
|
||||||
Ok(ImageInfo {
|
Ok(ImageInfo {
|
||||||
width: 640,
|
width: 640,
|
||||||
height: 480,
|
height: 480,
|
||||||
format: ImageFormat::Unknown,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -548,15 +544,6 @@ impl OpenCvFaceDetector {
|
||||||
struct ImageInfo {
|
struct ImageInfo {
|
||||||
width: i32,
|
width: i32,
|
||||||
height: i32,
|
height: i32,
|
||||||
format: ImageFormat,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
enum ImageFormat {
|
|
||||||
Jpeg,
|
|
||||||
Png,
|
|
||||||
Bmp,
|
|
||||||
Unknown,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,6 @@ pub struct RekognitionService {
|
||||||
collections: Arc<RwLock<HashMap<String, FaceCollection>>>,
|
collections: Arc<RwLock<HashMap<String, FaceCollection>>>,
|
||||||
indexed_faces: Arc<RwLock<HashMap<String, Vec<IndexedFace>>>>,
|
indexed_faces: Arc<RwLock<HashMap<String, Vec<IndexedFace>>>>,
|
||||||
face_details: Arc<RwLock<HashMap<String, RekognitionFace>>>,
|
face_details: Arc<RwLock<HashMap<String, RekognitionFace>>>,
|
||||||
liveness_sessions: Arc<RwLock<HashMap<String, LivenessSession>>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RekognitionService {
|
impl RekognitionService {
|
||||||
|
|
@ -561,7 +560,6 @@ impl RekognitionService {
|
||||||
collections: Arc::new(RwLock::new(HashMap::new())),
|
collections: Arc::new(RwLock::new(HashMap::new())),
|
||||||
indexed_faces: Arc::new(RwLock::new(HashMap::new())),
|
indexed_faces: Arc::new(RwLock::new(HashMap::new())),
|
||||||
face_details: Arc::new(RwLock::new(HashMap::new())),
|
face_details: Arc::new(RwLock::new(HashMap::new())),
|
||||||
liveness_sessions: Arc::new(RwLock::new(HashMap::new())),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -571,7 +569,6 @@ impl RekognitionService {
|
||||||
collections: Arc::new(RwLock::new(HashMap::new())),
|
collections: Arc::new(RwLock::new(HashMap::new())),
|
||||||
indexed_faces: Arc::new(RwLock::new(HashMap::new())),
|
indexed_faces: Arc::new(RwLock::new(HashMap::new())),
|
||||||
face_details: Arc::new(RwLock::new(HashMap::new())),
|
face_details: Arc::new(RwLock::new(HashMap::new())),
|
||||||
liveness_sessions: Arc::new(RwLock::new(HashMap::new())),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,8 @@ impl Default for OptimizerConfig {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct CachedMemberList {
|
struct CachedMemberList {
|
||||||
organization_id: Uuid,
|
|
||||||
member_ids: Vec<Uuid>,
|
member_ids: Vec<Uuid>,
|
||||||
total_count: usize,
|
total_count: usize,
|
||||||
cached_at: DateTime<Utc>,
|
|
||||||
expires_at: DateTime<Utc>,
|
expires_at: DateTime<Utc>,
|
||||||
is_partial: bool,
|
is_partial: bool,
|
||||||
loaded_pages: Vec<usize>,
|
loaded_pages: Vec<usize>,
|
||||||
|
|
@ -64,8 +62,6 @@ struct PermissionCacheKey {
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct CachedPermissions {
|
struct CachedPermissions {
|
||||||
permissions: Vec<String>,
|
permissions: Vec<String>,
|
||||||
roles: Vec<String>,
|
|
||||||
cached_at: DateTime<Utc>,
|
|
||||||
expires_at: DateTime<Utc>,
|
expires_at: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,14 +81,10 @@ pub struct PartitionManager {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DataPartition {
|
pub struct DataPartition {
|
||||||
id: Uuid,
|
pub id: Uuid,
|
||||||
organization_id: Uuid,
|
pub partition_key: String,
|
||||||
partition_key: String,
|
pub row_count: usize,
|
||||||
start_range: String,
|
pub size_bytes: u64,
|
||||||
end_range: String,
|
|
||||||
row_count: usize,
|
|
||||||
size_bytes: u64,
|
|
||||||
created_at: DateTime<Utc>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -292,10 +284,8 @@ impl LargeOrgOptimizer {
|
||||||
) {
|
) {
|
||||||
let now = Utc::now();
|
let now = Utc::now();
|
||||||
let cached = CachedMemberList {
|
let cached = CachedMemberList {
|
||||||
organization_id,
|
|
||||||
member_ids,
|
member_ids,
|
||||||
total_count,
|
total_count,
|
||||||
cached_at: now,
|
|
||||||
expires_at: now + chrono::Duration::seconds(self.config.member_cache_ttl_seconds as i64),
|
expires_at: now + chrono::Duration::seconds(self.config.member_cache_ttl_seconds as i64),
|
||||||
is_partial,
|
is_partial,
|
||||||
loaded_pages: pages,
|
loaded_pages: pages,
|
||||||
|
|
@ -333,7 +323,6 @@ impl LargeOrgOptimizer {
|
||||||
user_id: Uuid,
|
user_id: Uuid,
|
||||||
resource_type: &str,
|
resource_type: &str,
|
||||||
permissions: Vec<String>,
|
permissions: Vec<String>,
|
||||||
roles: Vec<String>,
|
|
||||||
) {
|
) {
|
||||||
let key = PermissionCacheKey {
|
let key = PermissionCacheKey {
|
||||||
organization_id,
|
organization_id,
|
||||||
|
|
@ -344,8 +333,6 @@ impl LargeOrgOptimizer {
|
||||||
let now = Utc::now();
|
let now = Utc::now();
|
||||||
let cached = CachedPermissions {
|
let cached = CachedPermissions {
|
||||||
permissions,
|
permissions,
|
||||||
roles,
|
|
||||||
cached_at: now,
|
|
||||||
expires_at: now + chrono::Duration::seconds(self.config.permission_cache_ttl_seconds as i64),
|
expires_at: now + chrono::Duration::seconds(self.config.permission_cache_ttl_seconds as i64),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -550,6 +537,10 @@ impl LargeOrgOptimizer {
|
||||||
&self.config
|
&self.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn partition_manager(&self) -> &Arc<PartitionManager> {
|
||||||
|
&self.partition_manager
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_statistics(&self) -> OptimizerStatistics {
|
pub async fn get_statistics(&self) -> OptimizerStatistics {
|
||||||
let stats = self.query_stats.read().await;
|
let stats = self.query_stats.read().await;
|
||||||
let member_cache = self.member_cache.read().await;
|
let member_cache = self.member_cache.read().await;
|
||||||
|
|
@ -590,18 +581,12 @@ impl PartitionManager {
|
||||||
&self,
|
&self,
|
||||||
organization_id: Uuid,
|
organization_id: Uuid,
|
||||||
partition_key: &str,
|
partition_key: &str,
|
||||||
start_range: &str,
|
|
||||||
end_range: &str,
|
|
||||||
) -> DataPartition {
|
) -> DataPartition {
|
||||||
let partition = DataPartition {
|
let partition = DataPartition {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
organization_id,
|
|
||||||
partition_key: partition_key.to_string(),
|
partition_key: partition_key.to_string(),
|
||||||
start_range: start_range.to_string(),
|
|
||||||
end_range: end_range.to_string(),
|
|
||||||
row_count: 0,
|
row_count: 0,
|
||||||
size_bytes: 0,
|
size_bytes: 0,
|
||||||
created_at: Utc::now(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut partitions = self.partitions.write().await;
|
let mut partitions = self.partitions.write().await;
|
||||||
|
|
@ -755,7 +740,6 @@ mod tests {
|
||||||
user_id,
|
user_id,
|
||||||
"bot",
|
"bot",
|
||||||
vec!["read".to_string(), "write".to_string()],
|
vec!["read".to_string(), "write".to_string()],
|
||||||
vec!["admin".to_string()],
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -792,10 +776,10 @@ mod tests {
|
||||||
let user_id2 = Uuid::new_v4();
|
let user_id2 = Uuid::new_v4();
|
||||||
|
|
||||||
optimizer
|
optimizer
|
||||||
.cache_permissions(org_id, user_id1, "bot", vec!["read".to_string()], vec![])
|
.cache_permissions(org_id, user_id1, "bot", vec!["read".to_string()])
|
||||||
.await;
|
.await;
|
||||||
optimizer
|
optimizer
|
||||||
.cache_permissions(org_id, user_id2, "bot", vec!["write".to_string()], vec![])
|
.cache_permissions(org_id, user_id2, "bot", vec!["write".to_string()])
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
optimizer.invalidate_permission_cache(org_id, None).await;
|
optimizer.invalidate_permission_cache(org_id, None).await;
|
||||||
|
|
@ -818,10 +802,10 @@ mod tests {
|
||||||
let user_id2 = Uuid::new_v4();
|
let user_id2 = Uuid::new_v4();
|
||||||
|
|
||||||
optimizer
|
optimizer
|
||||||
.cache_permissions(org_id, user_id1, "bot", vec!["read".to_string()], vec![])
|
.cache_permissions(org_id, user_id1, "bot", vec!["read".to_string()])
|
||||||
.await;
|
.await;
|
||||||
optimizer
|
optimizer
|
||||||
.cache_permissions(org_id, user_id2, "bot", vec!["write".to_string()], vec![])
|
.cache_permissions(org_id, user_id2, "bot", vec!["write".to_string()])
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
optimizer
|
optimizer
|
||||||
|
|
@ -891,9 +875,8 @@ mod tests {
|
||||||
let org_id = Uuid::new_v4();
|
let org_id = Uuid::new_v4();
|
||||||
|
|
||||||
let partition = manager
|
let partition = manager
|
||||||
.create_partition(org_id, "user_id", "a", "m")
|
.create_partition(org_id, "user_id")
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(partition.organization_id, org_id);
|
|
||||||
assert_eq!(partition.partition_key, "user_id");
|
assert_eq!(partition.partition_key, "user_id");
|
||||||
assert_eq!(partition.row_count, 0);
|
assert_eq!(partition.row_count, 0);
|
||||||
|
|
||||||
|
|
@ -906,7 +889,7 @@ mod tests {
|
||||||
let manager = PartitionManager::new(PartitionConfig::default());
|
let manager = PartitionManager::new(PartitionConfig::default());
|
||||||
let org_id = Uuid::new_v4();
|
let org_id = Uuid::new_v4();
|
||||||
|
|
||||||
let partition = manager.create_partition(org_id, "id", "0", "9").await;
|
let partition = manager.create_partition(org_id, "id").await;
|
||||||
|
|
||||||
assert!(!manager.should_split(&partition).await);
|
assert!(!manager.should_split(&partition).await);
|
||||||
assert!(manager.should_merge(&partition).await);
|
assert!(manager.should_merge(&partition).await);
|
||||||
|
|
|
||||||
|
|
@ -740,6 +740,17 @@ enum AuthError {
|
||||||
TokenExpired,
|
TokenExpired,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for AuthError {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::MissingToken => write!(f, "Missing authorization token"),
|
||||||
|
Self::InvalidFormat => write!(f, "Invalid authorization format"),
|
||||||
|
Self::InvalidToken(msg) => write!(f, "Invalid token: {msg}"),
|
||||||
|
Self::TokenExpired => write!(f, "Token expired"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Response Types
|
// Response Types
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
|
||||||
|
|
@ -244,8 +244,6 @@ pub struct OrganizationRbacService {
|
||||||
groups: Arc<RwLock<HashMap<Uuid, OrganizationGroup>>>,
|
groups: Arc<RwLock<HashMap<Uuid, OrganizationGroup>>>,
|
||||||
policies: Arc<RwLock<HashMap<Uuid, ResourcePolicy>>>,
|
policies: Arc<RwLock<HashMap<Uuid, ResourcePolicy>>>,
|
||||||
user_roles: Arc<RwLock<HashMap<(Uuid, Uuid), Vec<Uuid>>>>,
|
user_roles: Arc<RwLock<HashMap<(Uuid, Uuid), Vec<Uuid>>>>,
|
||||||
user_groups: Arc<RwLock<HashMap<Uuid, Vec<Uuid>>>>,
|
|
||||||
user_direct_permissions: Arc<RwLock<HashMap<Uuid, Vec<String>>>>,
|
|
||||||
audit_log: Arc<RwLock<Vec<AccessAuditEntry>>>,
|
audit_log: Arc<RwLock<Vec<AccessAuditEntry>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,8 +268,6 @@ impl OrganizationRbacService {
|
||||||
groups: Arc::new(RwLock::new(HashMap::new())),
|
groups: Arc::new(RwLock::new(HashMap::new())),
|
||||||
policies: Arc::new(RwLock::new(HashMap::new())),
|
policies: Arc::new(RwLock::new(HashMap::new())),
|
||||||
user_roles: Arc::new(RwLock::new(HashMap::new())),
|
user_roles: Arc::new(RwLock::new(HashMap::new())),
|
||||||
user_groups: Arc::new(RwLock::new(HashMap::new())),
|
|
||||||
user_direct_permissions: Arc::new(RwLock::new(HashMap::new())),
|
|
||||||
audit_log: Arc::new(RwLock::new(Vec::new())),
|
audit_log: Arc::new(RwLock::new(Vec::new())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ const PASSKEY_NAME_MAX_LENGTH: usize = 64;
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct FallbackAttemptTracker {
|
struct FallbackAttemptTracker {
|
||||||
attempts: u32,
|
attempts: u32,
|
||||||
first_attempt_at: DateTime<Utc>,
|
|
||||||
locked_until: Option<DateTime<Utc>>,
|
locked_until: Option<DateTime<Utc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -396,7 +395,6 @@ impl PasskeyService {
|
||||||
|
|
||||||
let tracker = attempts.entry(username.to_string()).or_insert(FallbackAttemptTracker {
|
let tracker = attempts.entry(username.to_string()).or_insert(FallbackAttemptTracker {
|
||||||
attempts: 0,
|
attempts: 0,
|
||||||
first_attempt_at: now,
|
|
||||||
locked_until: None,
|
locked_until: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue