@@ -101,6 +101,39 @@ async function generateGEXF() {
101
101
}
102
102
}
103
103
104
+ async function generateFullGEXF ( ) { // generate full graph with all users
105
+ await console . log ( 'Generating FULL graph...' ) ;
106
+
107
+ // Create a new graph
108
+ const graph = new Graph ( ) ;
109
+
110
+ // Fetch all mentions and user lookups
111
+ const mentions = await prisma . mention . findMany ( ) ;
112
+ const userLookups = await prisma . userLookup . findMany ( ) ;
113
+
114
+ // add nodes to the graph
115
+ userLookups . forEach ( ( user ) => {
116
+ graph . addNode ( user . id , { label : user . username } ) ;
117
+ } ) ;
118
+
119
+ // add edges to the graph
120
+ mentions . forEach ( ( mention ) => {
121
+ if ( graph . hasEdge ( mention . user1Id , mention . user2Id ) ) {
122
+ graph . updateEdgeAttribute ( mention . user1Id , mention . user2Id , 'weight' , ( w ) => w + mention . count ) ;
123
+ } else {
124
+ graph . addEdge ( mention . user1Id , mention . user2Id , { weight : mention . count } ) ;
125
+ }
126
+ } ) ;
127
+
128
+ // Export the graph
129
+ try {
130
+ fs . writeFileSync ( 'data/graph-full.gexf' , gexf . write ( graph ) ) ;
131
+ console . log ( 'Graph successfully exported to data/graph-full.gexf' ) ;
132
+ } catch ( err ) {
133
+ console . error ( 'Error exporting graph:' , err ) ;
134
+ }
135
+ }
136
+
104
137
// On client ready
105
138
client . once ( Events . ClientReady , ( readyClient ) => {
106
139
console . log ( `Ready! Logged in as ${ readyClient . user . tag } ` ) ;
@@ -249,6 +282,7 @@ client.on(Events.MessageCreate, async (message) => {
249
282
if ( mentionsCounter >= MENTIONS_THRESHOLD ) {
250
283
mentionsCounter = 0 ; // Reset counter
251
284
await generateGEXF ( ) ;
285
+ await generateFullGEXF ( ) ;
252
286
}
253
287
} ) ;
254
288
0 commit comments