-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_documents_data.py
More file actions
554 lines (476 loc) · 28.5 KB
/
Copy pathsetup_documents_data.py
File metadata and controls
554 lines (476 loc) · 28.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
"""
Add document and meeting transcript data to Neo4j organizational resilience PoC
Creates:
- Document and Topic nodes
- Meeting transcripts, emails, reports
- Relationships between documents, people, topics, projects, and processes
"""
from neo4j import GraphDatabase
from datetime import datetime, timedelta
# Neo4j connection
URI = "bolt://localhost:7687"
AUTH = ("neo4j", "neo4jadmin")
driver = GraphDatabase.driver(URI, auth=AUTH)
def clear_documents():
"""Clear existing documents and topics"""
with driver.session() as session:
session.run("""
MATCH (d:Document) DETACH DELETE d
""")
session.run("""
MATCH (t:Topic) DETACH DELETE t
""")
print("✓ Cleared existing documents and topics")
def create_topics():
"""Create topic nodes"""
with driver.session() as session:
topics = [
{"name": "Budget Planning", "category": "Finance",
"keywords": ["budget", "forecast", "spending", "costs"]},
{"name": "Cloud Migration", "category": "Technology",
"keywords": ["aws", "azure", "cloud", "infrastructure"]},
{"name": "Product Roadmap", "category": "Strategy",
"keywords": ["features", "product", "roadmap", "planning"]},
{"name": "Security Compliance", "category": "Compliance",
"keywords": ["security", "gdpr", "compliance", "audit"]},
{"name": "Customer Success", "category": "Operations",
"keywords": ["customer", "support", "satisfaction", "retention"]},
{"name": "Team Building", "category": "HR",
"keywords": ["culture", "team", "morale", "engagement"]},
{"name": "Performance Optimization", "category": "Technology",
"keywords": ["performance", "optimization", "scalability"]},
{"name": "Market Analysis", "category": "Strategy",
"keywords": ["market", "competition", "analysis", "trends"]},
{"name": "API Development", "category": "Technology",
"keywords": ["api", "rest", "integration", "endpoints"]},
{"name": "Data Analytics", "category": "Analytics",
"keywords": ["data", "analytics", "metrics", "reporting"]}
]
for topic in topics:
session.run("""
CREATE (t:Topic {
name: $name,
category: $category,
keywords: $keywords,
created_at: datetime()
})
""", **topic)
print(f"✓ Created {len(topics)} topics")
def create_documents():
"""Create document nodes with realistic content"""
with driver.session() as session:
# Meeting transcripts
meetings = [
{
"id": "meeting_2025_12_01_q4_planning",
"title": "Q4 Budget Planning Meeting",
"type": "meeting_transcript",
"date": "2025-12-01",
"summary": "Discussed Q4 budget allocation across departments. Engineering needs 20% increase for cloud migration. Sales requesting additional headcount. Decision: Approve engineering budget increase, defer sales hiring to Q1 2026.",
"content": """
[2025-12-01 14:00] Q4 Budget Planning Meeting
Attendees: Alice Johnson, Bob Smith, Carol White, Diana Chen
Alice: Let's review the Q4 budget. Engineering is requesting a 20% increase to accelerate our cloud migration to AWS. Bob, can you walk us through the breakdown?
Bob: Sure. We need $150K for infrastructure costs, $80K for additional tooling, and we want to bring in two cloud architects on contract for $120K combined. This migration is critical for our scalability goals.
Carol: Sales perspective - we're seeing increased customer interest but need two more account executives to handle the pipeline. That's about $200K including benefits and tools.
Alice: Diana, what's your take from a financial standpoint?
Diana: The engineering investment aligns with our technical debt reduction goals and the board's push for scalability. However, sales hiring can wait until Q1 when we have better revenue predictability. I recommend approving engineering's request and deferring sales expansion.
Alice: Agreed. Bob, you're greenlit for the cloud migration budget. Carol, let's revisit sales headcount in January. I'll document this and send approvals through by end of week.
[Action Items]
- Alice: Send formal budget approval to engineering (Due: Dec 5)
- Bob: Provide detailed migration timeline (Due: Dec 8)
- Carol: Prepare Q1 sales hiring justification (Due: Jan 10)
- Diana: Update financial forecast models (Due: Dec 15)
""",
"attendees": ["Alice Johnson", "Bob Smith", "Carol White", "Diana Chen"],
"authors": ["Alice Johnson"],
"topics": [
{"name": "Budget Planning", "relevance": 0.95},
{"name": "Cloud Migration", "relevance": 0.85}
],
"related_projects": ["Cloud Migration Initiative"],
"related_processes": []
},
{
"id": "meeting_2025_11_28_security_review",
"title": "Security Compliance Quarterly Review",
"type": "meeting_transcript",
"date": "2025-11-28",
"summary": "Quarterly security audit review. Discussed GDPR compliance gaps, penetration test findings, and action plan for SOC 2 certification. All critical vulnerabilities resolved. Minor issues remain in legacy authentication system.",
"content": """
[2025-11-28 10:00] Security Compliance Quarterly Review
Attendees: Eve Davis, Frank Miller, Grace Lee, Bob Smith
Eve: Thanks everyone for joining. Let's review our Q4 security audit results. Frank, can you summarize the penetration test findings?
Frank: We completed the external penetration test last week. Good news - no critical vulnerabilities found. We did identify three medium-severity issues in our legacy authentication system that Grace's team is already addressing.
Grace: Yes, we've patched two of the three. The last one requires a broader refactor of our session management, which ties into Bob's API modernization project.
Bob: Right. We're rebuilding authentication as part of the new API gateway. That should resolve the legacy auth issues permanently. Target completion is end of January.
Eve: Excellent. On GDPR compliance - we've completed all data mapping exercises and implemented the right-to-deletion workflows. We're now 98% compliant. The remaining 2% is documenting data retention policies for archived logs.
Frank: For SOC 2, we're on track for Q2 certification. Main gap is continuous monitoring, which we're implementing through our new observability platform.
Eve: Great work everyone. Let's keep pushing on these initiatives. Our customers are increasingly asking about security certifications.
[Action Items]
- Grace: Complete final auth system patch (Due: Dec 15)
- Bob: Deliver new API gateway with modern auth (Due: Jan 31)
- Eve: Finalize data retention policy documentation (Due: Dec 20)
- Frank: Implement continuous security monitoring (Due: Feb 28)
""",
"attendees": ["Eve Davis", "Frank Miller", "Grace Lee", "Bob Smith"],
"authors": ["Eve Davis"],
"topics": [
{"name": "Security Compliance", "relevance": 0.98},
{"name": "API Development", "relevance": 0.65}
],
"related_projects": ["API Modernization"],
"related_processes": ["Security Audit Process"]
},
{
"id": "meeting_2025_12_05_product_roadmap",
"title": "2026 Product Roadmap Planning",
"type": "meeting_transcript",
"date": "2025-12-05",
"summary": "Strategic planning for 2026 product roadmap. Priorities: Advanced analytics dashboard, mobile app launch, third-party integrations. Engineering capacity constraints discussed. Decision to hire two senior engineers in Q1.",
"content": """
[2025-12-05 15:00] 2026 Product Roadmap Planning
Attendees: Alice Johnson, Bob Smith, Helen Martinez, Ivan Torres, Grace Lee
Alice: Let's finalize our 2026 product priorities. We have three major initiatives on the table: advanced analytics, mobile app, and third-party integrations. Helen, what's the customer feedback saying?
Helen: Analytics dashboard is the #1 request - 67% of enterprise customers mentioned it in recent surveys. Mobile app is #2 at 45%. Integrations are important but less urgent.
Bob: From an engineering perspective, the analytics work is complex. We need strong data pipeline expertise, which means either upskilling current team or hiring. Ivan, thoughts on the data architecture?
Ivan: I can lead the data pipeline design, but I'll need at least one senior data engineer to help implement it. The mobile app is more straightforward - Grace's team has the skills, just needs dedicated time.
Grace: Agreed. If we prioritize analytics and mobile, we'll need to defer some technical debt work. I'm comfortable with that tradeoff for 2-3 quarters.
Alice: Okay, decision time. We'll prioritize analytics in Q1-Q2, mobile app in Q2-Q3, and push integrations to H2. Bob, work with HR to hire a senior data engineer and one senior full-stack engineer. Budget approved.
Helen: I'll update customers on the timeline. This aligns well with our enterprise sales strategy.
[Action Items]
- Bob: Draft job descriptions for two senior engineers (Due: Dec 12)
- Ivan: Create data pipeline architecture proposal (Due: Dec 18)
- Grace: Scope mobile app MVP requirements (Due: Dec 20)
- Helen: Communicate roadmap to top 20 customers (Due: Dec 22)
- Alice: Present roadmap to board (Due: Jan 15)
""",
"attendees": ["Alice Johnson", "Bob Smith", "Helen Martinez", "Ivan Torres", "Grace Lee"],
"authors": ["Alice Johnson"],
"topics": [
{"name": "Product Roadmap", "relevance": 0.95},
{"name": "Data Analytics", "relevance": 0.80},
{"name": "API Development", "relevance": 0.50}
],
"related_projects": ["Data Pipeline Upgrade"],
"related_processes": []
},
{
"id": "meeting_2025_11_20_customer_escalation",
"title": "Major Customer Escalation - TechCorp",
"type": "meeting_transcript",
"date": "2025-11-20",
"summary": "Emergency meeting regarding TechCorp performance issues. Platform response times degraded 3x during their peak usage. Root cause: database query optimization needed. Immediate action plan created with 48-hour resolution target.",
"content": """
[2025-11-20 09:00] URGENT: TechCorp Customer Escalation
Attendees: Bob Smith, Ivan Torres, Helen Martinez, Karen Moore
Helen: Thanks for jumping on this quickly. TechCorp is one of our largest customers and they're experiencing severe performance issues. Their CEO called our CEO directly. Response times are 3x slower than normal during their peak usage hours.
Bob: Ivan and I were investigating overnight. We found the issue - it's a query performance problem in our reporting module. When TechCorp pulls large reports with their data volume, it's causing database locks that affect all their users.
Ivan: Specifically, it's the aggregation queries. We weren't expecting any single customer to have 10 million records. Our query optimizer doesn't handle that scale well.
Karen: I can help optimize the queries. I've dealt with similar issues at scale. We need to add proper indexes and potentially implement query result caching.
Bob: Karen, can you work with Ivan to implement fixes? This is priority one. Everything else is on hold.
Helen: I need to give TechCorp a timeline. What's realistic?
Ivan: With Karen's help, we can deploy optimized queries and new indexes within 48 hours. That should bring response times back to acceptable levels. Longer term, we need to architect for this scale across the platform.
Bob: Agreed. Let's fix the immediate issue, then I'll schedule a broader performance review for next week.
Helen: I'll call TechCorp's VP of Engineering with the 48-hour timeline and keep them updated every 8 hours.
[Action Items]
- Ivan & Karen: Implement query optimization (Due: Nov 22, 9am)
- Bob: Deploy optimizations to production (Due: Nov 22, 2pm)
- Helen: Customer communication every 8 hours (Ongoing)
- Bob: Schedule platform performance review (Due: Nov 27)
""",
"attendees": ["Bob Smith", "Ivan Torres", "Helen Martinez", "Karen Moore"],
"authors": ["Bob Smith"],
"topics": [
{"name": "Performance Optimization", "relevance": 0.95},
{"name": "Customer Success", "relevance": 0.85},
{"name": "Data Analytics", "relevance": 0.60}
],
"related_projects": [],
"related_processes": ["Incident Response"]
}
]
# Add meetings to database
for meeting in meetings:
# Create document
session.run("""
CREATE (d:Document {
id: $id,
title: $title,
type: $type,
date: date($date),
summary: $summary,
content: $content,
created_at: datetime()
})
""", id=meeting["id"], title=meeting["title"], type=meeting["type"],
date=meeting["date"], summary=meeting["summary"], content=meeting["content"])
# Link attendees
for attendee in meeting["attendees"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (e:Employee {name: $name})
CREATE (e)-[:ATTENDED]->(d)
""", doc_id=meeting["id"], name=attendee)
# Link authors
for author in meeting["authors"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (e:Employee {name: $name})
CREATE (e)-[:AUTHORED]->(d)
""", doc_id=meeting["id"], name=author)
# Link topics
for topic in meeting["topics"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (t:Topic {name: $topic_name})
CREATE (d)-[:DISCUSSES {relevance: $relevance}]->(t)
""", doc_id=meeting["id"], topic_name=topic["name"], relevance=topic["relevance"])
# Link projects
for project in meeting["related_projects"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (p:Project {name: $project_name})
CREATE (d)-[:RELATES_TO]->(p)
""", doc_id=meeting["id"], project_name=project)
# Link processes
for process in meeting["related_processes"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (proc:Process {name: $process_name})
CREATE (d)-[:IMPACTS]->(proc)
""", doc_id=meeting["id"], process_name=process)
print(f"✓ Created {len(meetings)} meeting transcripts")
# Technical documents
documents = [
{
"id": "doc_cloud_migration_plan",
"title": "AWS Cloud Migration Architecture Plan",
"type": "technical_document",
"date": "2025-12-03",
"summary": "Comprehensive plan for migrating infrastructure to AWS. Includes architecture diagrams, migration phases, rollback procedures, and cost projections. Estimated timeline: 4 months. Total cost: $350K.",
"content": "Detailed technical specification for AWS migration including VPC design, security groups, IAM policies, database migration strategy using DMS, and containerization with ECS...",
"authors": ["Bob Smith", "Frank Miller"],
"mentioned": ["Ivan Torres", "Grace Lee"],
"topics": [
{"name": "Cloud Migration", "relevance": 0.98},
{"name": "Security Compliance", "relevance": 0.75}
],
"related_projects": ["Cloud Migration Initiative"],
"related_processes": []
},
{
"id": "doc_api_standards",
"title": "REST API Design Standards v2.0",
"type": "technical_document",
"date": "2025-11-15",
"summary": "Updated API design standards including authentication patterns, error handling, versioning strategy, and rate limiting. Mandatory for all new API development starting Q1 2026.",
"content": "Standard REST API design patterns including resource naming conventions, HTTP methods usage, status codes, pagination, filtering, authentication using OAuth 2.0...",
"authors": ["Grace Lee", "Bob Smith"],
"mentioned": ["Jack Thompson"],
"topics": [
{"name": "API Development", "relevance": 0.95},
{"name": "Security Compliance", "relevance": 0.70}
],
"related_projects": ["API Modernization"],
"related_processes": []
},
{
"id": "doc_data_governance_policy",
"title": "Data Governance and Privacy Policy",
"type": "policy_document",
"date": "2025-11-10",
"summary": "Organizational data governance policy covering data classification, access controls, retention policies, and privacy compliance (GDPR, CCPA). Applies to all data handling processes.",
"content": "Data classification levels (Public, Internal, Confidential, Restricted), access control matrix, data retention schedules by type, right-to-deletion procedures...",
"authors": ["Eve Davis", "Diana Chen"],
"mentioned": ["Alice Johnson", "Ivan Torres"],
"topics": [
{"name": "Security Compliance", "relevance": 0.95},
{"name": "Data Analytics", "relevance": 0.70}
],
"related_projects": [],
"related_processes": ["Compliance Review Process", "Security Audit Process"]
},
{
"id": "doc_q3_performance_report",
"title": "Q3 2025 System Performance Analysis",
"type": "report",
"date": "2025-10-15",
"summary": "Quarterly system performance metrics. Average API response time: 245ms (up from 180ms in Q2). Database query time increased 35%. Identified scaling bottlenecks. Recommendations: implement caching layer, optimize top 20 slow queries.",
"content": "Detailed performance metrics including API endpoint response times, database query analysis, infrastructure utilization, error rates, and performance trends...",
"authors": ["Ivan Torres", "Karen Moore"],
"mentioned": ["Bob Smith", "Grace Lee"],
"topics": [
{"name": "Performance Optimization", "relevance": 0.90},
{"name": "Data Analytics", "relevance": 0.75}
],
"related_projects": [],
"related_processes": ["Performance Monitoring"]
},
{
"id": "email_customer_feedback_summary",
"title": "Customer Feedback Summary - November 2025",
"type": "email",
"date": "2025-12-02",
"summary": "Monthly customer feedback compilation. Top requests: advanced analytics (67%), mobile app (45%), Salesforce integration (38%). Overall satisfaction score: 8.2/10 (up from 7.9). Three customers at risk of churn due to performance issues.",
"content": "From: Helen Martinez\nTo: Alice Johnson, Bob Smith, Product Team\nSubject: November Customer Feedback Summary\n\nHi team,\n\nHere's the monthly customer feedback roundup...\n\nTop Feature Requests:\n1. Advanced analytics dashboard - 67% of enterprise customers\n2. Mobile app - 45% of all customers\n3. Salesforce integration - 38% of sales-focused customers\n\nSatisfaction Metrics:\n- Overall: 8.2/10 (↑ from 7.9 in October)\n- Support response time: 9.1/10\n- Product reliability: 7.8/10 (↓ from 8.3 - concerning)\n- Feature completeness: 7.5/10\n\nAt-Risk Customers:\n- TechCorp: Performance issues (now resolved)\n- DataFlow Inc: Waiting for analytics features\n- MegaSales Co: Need Salesforce integration\n\nRecommendation: Prioritize analytics and integrations in 2026 roadmap.\n\nBest,\nHelen",
"authors": ["Helen Martinez"],
"mentioned": ["Alice Johnson", "Bob Smith"],
"topics": [
{"name": "Customer Success", "relevance": 0.90},
{"name": "Product Roadmap", "relevance": 0.80}
],
"related_projects": [],
"related_processes": []
},
{
"id": "doc_onboarding_guide_v3",
"title": "Engineering Onboarding Guide v3.1",
"type": "documentation",
"date": "2025-11-01",
"summary": "Updated engineering onboarding guide covering development environment setup, coding standards, deployment procedures, and team practices. Includes Python, React, and AWS infrastructure setup instructions.",
"content": "Welcome to the Engineering team! This guide covers: 1) Development environment setup, 2) Repository structure, 3) Coding standards and review process, 4) Testing requirements, 5) Deployment procedures, 6) Team communication...",
"authors": ["Jack Thompson", "Grace Lee"],
"mentioned": ["Bob Smith", "Laura Anderson"],
"topics": [
{"name": "Team Building", "relevance": 0.70},
{"name": "API Development", "relevance": 0.50}
],
"related_projects": [],
"related_processes": ["Code Review Process"]
}
]
# Add documents to database
for doc in documents:
# Create document
session.run("""
CREATE (d:Document {
id: $id,
title: $title,
type: $type,
date: date($date),
summary: $summary,
content: $content,
created_at: datetime()
})
""", id=doc["id"], title=doc["title"], type=doc["type"],
date=doc["date"], summary=doc["summary"], content=doc["content"])
# Link authors
for author in doc["authors"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (e:Employee {name: $name})
CREATE (e)-[:AUTHORED]->(d)
""", doc_id=doc["id"], name=author)
# Link mentioned people
for person in doc.get("mentioned", []):
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (e:Employee {name: $name})
CREATE (e)-[:MENTIONED_IN]->(d)
""", doc_id=doc["id"], name=person)
# Link topics
for topic in doc["topics"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (t:Topic {name: $topic_name})
CREATE (d)-[:DISCUSSES {relevance: $relevance}]->(t)
""", doc_id=doc["id"], topic_name=topic["name"], relevance=topic["relevance"])
# Link projects
for project in doc["related_projects"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (p:Project {name: $project_name})
CREATE (d)-[:RELATES_TO]->(p)
""", doc_id=doc["id"], project_name=project)
# Link processes
for process in doc["related_processes"]:
session.run("""
MATCH (d:Document {id: $doc_id})
MATCH (proc:Process {name: $process_name})
CREATE (d)-[:IMPACTS]->(proc)
""", doc_id=doc["id"], process_name=process)
print(f"✓ Created {len(documents)} documents")
def create_topic_relationships():
"""Create relationships between related topics"""
with driver.session() as session:
relationships = [
("Cloud Migration", "Performance Optimization"),
("Cloud Migration", "Security Compliance"),
("API Development", "Security Compliance"),
("Data Analytics", "Performance Optimization"),
("Product Roadmap", "Customer Success"),
("Security Compliance", "Data Analytics")
]
for topic1, topic2 in relationships:
session.run("""
MATCH (t1:Topic {name: $topic1})
MATCH (t2:Topic {name: $topic2})
CREATE (t1)-[:RELATED_TO]->(t2)
""", topic1=topic1, topic2=topic2)
print(f"✓ Created {len(relationships)} topic relationships")
def print_summary():
"""Print summary of document data"""
with driver.session() as session:
# Count documents by type
result = session.run("""
MATCH (d:Document)
RETURN d.type as type, count(*) as count
ORDER BY count DESC
""")
print("\n=== Document Summary ===")
for record in result:
print(f" {record['type']}: {record['count']}")
# Count topics
result = session.run("MATCH (t:Topic) RETURN count(*) as count")
print(f" Total topics: {result.single()['count']}")
# Count relationships
result = session.run("""
MATCH ()-[r:ATTENDED|AUTHORED|MENTIONED_IN|DISCUSSES|RELATES_TO|IMPACTS]->()
RETURN type(r) as rel_type, count(*) as count
ORDER BY count DESC
""")
print("\n=== Document Relationships ===")
for record in result:
print(f" {record['rel_type']}: {record['count']}")
# Sample queries
print("\n=== Sample Insights ===")
# Most documented employee
result = session.run("""
MATCH (e:Employee)-[r:ATTENDED|AUTHORED|MENTIONED_IN]->(d:Document)
WITH e, count(DISTINCT d) as doc_count
ORDER BY doc_count DESC
LIMIT 1
RETURN e.name as name, doc_count
""")
record = result.single()
print(f" Most active in documents: {record['name']} ({record['doc_count']} documents)")
# Most discussed topic
result = session.run("""
MATCH (d:Document)-[r:DISCUSSES]->(t:Topic)
WITH t, count(d) as mentions, avg(r.relevance) as avg_relevance
ORDER BY mentions DESC
LIMIT 1
RETURN t.name as topic, mentions, avg_relevance
""")
record = result.single()
print(f" Most discussed topic: {record['topic']} ({record['mentions']} documents, avg relevance: {record['avg_relevance']:.2f})")
def main():
print("Setting up document and topic data for Neo4j organizational resilience PoC\n")
try:
clear_documents()
create_topics()
create_documents()
create_topic_relationships()
print_summary()
print("\n✅ Document data setup complete!")
print("\nTry these queries in Neo4j Browser:")
print(" 1. MATCH (e:Employee)-[:ATTENDED]->(d:Document) RETURN e, d")
print(" 2. MATCH (d:Document)-[:DISCUSSES]->(t:Topic) WHERE d.type='meeting_transcript' RETURN d, t")
print(" 3. MATCH path=(e:Employee)-[:AUTHORED]->(d:Document)-[:RELATES_TO]->(p:Project) RETURN path")
except Exception as e:
print(f"\n❌ Error: {e}")
finally:
driver.close()
if __name__ == "__main__":
main()