Changeset 14813
- Timestamp:
- 04/14/2026 07:11:02 AM (4 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications-db.php
r14806 r14813 258 258 'name' => $name 259 259 ) ); 260 } 261 262 /** 263 * Get tickets with the most multi-person activity in a given time window. 264 * 265 * Returns tickets sorted by number of distinct participants, then by 266 * total change count. Only includes tickets with activity from at least 267 * $min_participants distinct people. 268 * 269 * @param int $days Number of days to look back. 270 * @param int $min_participants Minimum distinct authors to qualify. 271 * @param int $limit Maximum tickets to return. 272 * @return array 273 */ 274 function get_active_tickets( $days = 14, $min_participants = 3, $limit = 15 ) { 275 $days = max( 1, min( 90, (int) $days ) ); 276 $min_participants = max( 2, (int) $min_participants ); 277 $limit = max( 1, min( 50, (int) $limit ) ); 278 279 // Trac stores timestamps in microseconds. 280 $since = ( time() - ( 86400 * $days ) ) * 1000000; 281 282 $rows = $this->db->get_results( $this->db->prepare( 283 "SELECT tc.ticket, 284 t.summary, 285 t.status, 286 t.type, 287 t.component, 288 t.priority, 289 t.milestone, 290 t.owner, 291 COUNT(*) AS change_count, 292 COUNT(DISTINCT tc.author) AS participant_count, 293 MAX(tc.time) AS last_activity 294 FROM ticket_change tc 295 INNER JOIN ticket t ON tc.ticket = t.id 296 WHERE tc.time >= %s 297 AND tc.field <> 'cc' 298 AND NOT (tc.field = 'comment' AND tc.newvalue = '') 299 GROUP BY tc.ticket 300 HAVING participant_count >= %d 301 ORDER BY participant_count DESC, change_count DESC 302 LIMIT %d", 303 $since, 304 $min_participants, 305 $limit 306 ), ARRAY_A ); 307 308 if ( ! $rows ) { 309 return array(); 310 } 311 312 // Normalize types for JSON. 313 foreach ( $rows as &$row ) { 314 $row['ticket'] = (int) $row['ticket']; 315 $row['change_count'] = (int) $row['change_count']; 316 $row['participant_count'] = (int) $row['participant_count']; 317 $row['last_activity'] = (int) ( $row['last_activity'] / 1000000 ); // Convert to unix seconds. 318 } 319 320 return $rows; 260 321 } 261 322
Note: See TracChangeset
for help on using the changeset viewer.