Insert fraud detection test data (accounts, merchants, transactions) Call this after setup_graph() to populate a fresh graph with fraud data
(&self)
| 133 | /// Insert fraud detection test data (accounts, merchants, transactions) |
| 134 | /// Call this after setup_graph() to populate a fresh graph with fraud data |
| 135 | pub fn insert_fraud_data(&self) -> Result<(), String> { |
| 136 | // Create accounts |
| 137 | for i in 1..=50 { |
| 138 | let balance = (i as f64) * 100.0; |
| 139 | let account_type = match i % 4 { |
| 140 | 0 => "checking", |
| 141 | 1 => "savings", |
| 142 | 2 => "business", |
| 143 | _ => "investment", |
| 144 | }; |
| 145 | let account_status = if i % 10 == 0 { "inactive" } else { "active" }; |
| 146 | let risk_score = (i % 100) as f64 / 10.0; // Risk score from 0.0 to 9.9 |
| 147 | self.query(&format!( |
| 148 | "INSERT (a:Account {{id: {}, account_number: 'ACC{}', name: 'Account{}', balance: {}, status: '{}', account_status: '{}', account_type: '{}', risk_score: {}}})", |
| 149 | i, i, i, balance, account_status, account_status, account_type, risk_score |
| 150 | ))?; |
| 151 | } |
| 152 | |
| 153 | // Create merchants |
| 154 | for i in 1..=20 { |
| 155 | self.query(&format!( |
| 156 | "INSERT (m:Merchant {{id: {}, name: 'Merchant{}', category: 'retail'}})", |
| 157 | i, i |
| 158 | ))?; |
| 159 | } |
| 160 | |
| 161 | // Create transactions (relationships between accounts and merchants) |
| 162 | for i in 1..=100 { |
| 163 | let account_id = ((i - 1) % 50) + 1; |
| 164 | let merchant_id = ((i - 1) % 20) + 1; |
| 165 | let amount = 50.0 + ((i % 30) as f64); |
| 166 | |
| 167 | self.query(&format!( |
| 168 | "MATCH (a:Account {{id: {}}}), (m:Merchant {{id: {}}}) |
| 169 | INSERT (a)-[:Transaction {{amount: {}, timestamp: {}}}]->(m)", |
| 170 | account_id, merchant_id, amount, i |
| 171 | ))?; |
| 172 | } |
| 173 | |
| 174 | // Create purchases (accounts to merchants) |
| 175 | for i in 1..=50 { |
| 176 | let account_id = ((i - 1) % 50) + 1; |
| 177 | let merchant_id = ((i - 1) % 20) + 1; |
| 178 | let amount = ((i % 30) + 1) as f64 * 3.5; |
| 179 | |
| 180 | self.query(&format!( |
| 181 | "MATCH (a:Account {{id: {}}}), (m:Merchant {{id: {}}}) |
| 182 | INSERT (a)-[:Purchase {{amount: {}, timestamp: {}}}]->(m)", |
| 183 | account_id, |
| 184 | merchant_id, |
| 185 | amount, |
| 186 | i + 100 |
| 187 | ))?; |
| 188 | } |
| 189 | |
| 190 | Ok(()) |
| 191 | } |
| 192 |
no test coverage detected