@@ -27,7 +27,8 @@ export const injectAuditData: Script = {
2727 const actions = [
2828 'user.performed_code_search' ,
2929 'user.performed_find_references' ,
30- 'user.performed_goto_definition'
30+ 'user.performed_goto_definition' ,
31+ 'user.created_ask_chat'
3132 ] ;
3233
3334 // Generate data for the last 90 days
@@ -119,6 +120,37 @@ export const injectAuditData: Script = {
119120 }
120121 } ) ;
121122 }
123+
124+ // Generate Ask chat sessions (0-2 per day on weekdays, 0-1 on weekends)
125+ const askChats = isWeekend
126+ ? Math . floor ( Math . random ( ) * 2 ) // 0-1 on weekends
127+ : Math . floor ( Math . random ( ) * 3 ) ; // 0-2 on weekdays
128+
129+ // Create Ask chat records
130+ for ( let i = 0 ; i < askChats ; i ++ ) {
131+ const timestamp = new Date ( currentDate ) ;
132+ if ( isWeekend ) {
133+ timestamp . setHours ( 9 + Math . floor ( Math . random ( ) * 12 ) ) ;
134+ timestamp . setMinutes ( Math . floor ( Math . random ( ) * 60 ) ) ;
135+ } else {
136+ timestamp . setHours ( 9 + Math . floor ( Math . random ( ) * 9 ) ) ;
137+ timestamp . setMinutes ( Math . floor ( Math . random ( ) * 60 ) ) ;
138+ }
139+ timestamp . setSeconds ( Math . floor ( Math . random ( ) * 60 ) ) ;
140+
141+ await prisma . audit . create ( {
142+ data : {
143+ timestamp,
144+ action : 'user.created_ask_chat' ,
145+ actorId : userId ,
146+ actorType : 'user' ,
147+ targetId : orgId . toString ( ) ,
148+ targetType : 'org' ,
149+ sourcebotVersion : '1.0.0' ,
150+ orgId
151+ }
152+ } ) ;
153+ }
122154 }
123155 }
124156
0 commit comments