Skip to content

Commit b86b746

Browse files
Abuudiiiclaude
andauthored
Database Seeding: Rewards, Partners & Demo Data (#4)
* Add database seeding script with comprehensive Calgary demo data - Created idempotent seed script with realistic CivicPulse data - 10 Calgary neighborhoods (Beltline, Inglewood, Kensington, etc.) - 20 users including Sarah Chen (main demo user) and city officials - 20 civic issues across all priority levels (4 critical, 8 high, 5 medium, 3 low) - 160 activities showing sustainable transportation engagement - 5 active challenges (bike, transit, walking, reporting) - 23 user-challenge assignments with varied completion status Demo credentials: - Citizen: sarah@civicpulse.ca / password123 - Officials: alex.park@calgary.ca, jordan.lee@calgary.ca, casey.wong@calgary.ca / password123 Script features: - Clears existing data for clean re-runs - Sarah's profile optimized for demo (850 points, silver rank, 45.3kg carbon saved) - Varied issue types across infrastructure, safety, environmental, accessibility - Realistic activity patterns over last 30 days - Geographic distribution across neighborhoods Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Add comprehensive README for database seeding Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Add comprehensive database seeding with rewards and partners - Created 5 reward partners (Amazon, Starbucks, Best Buy, Calgary Transit, City of Calgary) - Added 17 diverse rewards across 6 categories - Implemented realistic activity data with carbon savings - Added challenge seeding with various types - Enhanced user data with points and ranks - Created neighborhood and civic issue data - Added comprehensive cleanup for fresh seeding 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0ea88fa commit b86b746

File tree

6 files changed

+2158
-0
lines changed

6 files changed

+2158
-0
lines changed

seeding/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.env

seeding/README.md

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# CivicPulse Database Seeding
2+
3+
Comprehensive database seeding script for CivicPulse demo with realistic Calgary data.
4+
5+
## Quick Start
6+
7+
```bash
8+
cd seeding
9+
npm install
10+
npm run seed
11+
```
12+
13+
## What Gets Created
14+
15+
### Neighborhoods (10)
16+
- Beltline
17+
- Inglewood
18+
- Kensington
19+
- Mission
20+
- Bridgeland
21+
- Ramsay
22+
- Victoria Park
23+
- East Village
24+
- Hillhurst
25+
- Sunnyside
26+
27+
### Users (20)
28+
29+
**Main Demo User:**
30+
- Sarah Chen (sarah@civicpulse.ca)
31+
- Silver rank, 850 points
32+
- 45.3 kg carbon saved
33+
- Lives in Beltline
34+
- Active in challenges and issue reporting
35+
36+
**City Officials (3):**
37+
- Alex Park (alex.park@calgary.ca) - Public Works Department
38+
- Jordan Lee (jordan.lee@calgary.ca) - Parks Department
39+
- Casey Wong (casey.wong@calgary.ca) - Transportation Department
40+
41+
**Citizens (16):**
42+
- Varied ranks: 1 platinum, 3 gold, 3 silver, 9 bronze
43+
- Points range: 200 - 2100
44+
- Distributed across all neighborhoods
45+
46+
**Password for all users:** `password123`
47+
48+
### Issues (20)
49+
50+
**Priority Distribution:**
51+
- Critical: 4 issues (flooding, traffic light out, tree hazard, accessibility blocker)
52+
- High: 8 issues (potholes, streetlights, dumping, infrastructure)
53+
- Medium: 5 issues (park maintenance, signage, graffiti)
54+
- Low: 3 issues (suggestions and improvement requests)
55+
56+
**Key Demo Issue:**
57+
- Sarah's pothole report in Beltline bike lane (high priority, open status)
58+
59+
**Categories:**
60+
- Infrastructure
61+
- Safety
62+
- Environmental
63+
- Accessibility
64+
65+
**Status Distribution:**
66+
- Open: ~15 issues
67+
- In Progress: ~10 issues
68+
- Resolved: ~5 issues
69+
70+
### Activities (160)
71+
72+
**Sarah's Activities (14):**
73+
- Recent sustainable transportation trips
74+
- Mix of biking, walking, and transit
75+
- Total carbon saved aligns with profile (45.3 kg)
76+
77+
**Other Users (146):**
78+
- 3-10 activities per user
79+
- Random distribution over last 30 days
80+
- Varied activity types and distances
81+
82+
### Challenges (5)
83+
84+
1. **Bike to Work Week**
85+
- City issued
86+
- 100 points reward
87+
- Nov 1-8, 2025
88+
89+
2. **Car-Free November**
90+
- City issued
91+
- 200 points reward
92+
- Nov 1-30, 2025
93+
94+
3. **Transit Champion**
95+
- City issued
96+
- 75 points reward
97+
- Nov 4-11, 2025
98+
99+
4. **Walking Warrior**
100+
- AI generated
101+
- 150 points reward
102+
- Nov 1-30, 2025
103+
104+
5. **Community Reporter**
105+
- City issued
106+
- 50 points reward
107+
- Nov 1-15, 2025
108+
109+
### User Challenges (23)
110+
111+
- Sarah joined "Bike to Work Week" (in progress)
112+
- Sarah joined "Community Reporter" (in progress)
113+
- 11 other active users with 1-3 challenges each
114+
- ~40% completion rate across all assignments
115+
116+
## Features
117+
118+
### Idempotent Seeding
119+
- Clears all existing data before seeding
120+
- Can be run multiple times safely
121+
- Respects foreign key constraints
122+
123+
### Realistic Data
124+
- Calgary neighborhood names
125+
- Diverse, realistic user names
126+
- Detailed issue descriptions
127+
- Varied activity patterns
128+
- Appropriate carbon savings calculations
129+
130+
### Demo Optimized
131+
- Sarah's profile perfect for citizen demo
132+
- Mix of issue priorities for dashboard impact
133+
- Active challenges showing engagement
134+
- Recent activity data for leaderboards
135+
136+
## Database Connection
137+
138+
Uses environment variable from `.env`:
139+
```
140+
DATABASE_URL="postgresql://postgres:hwJlkaepEZvIsvqNVslABgkPvGfHAbVp@caboose.proxy.rlwy.net:37488/railway"
141+
```
142+
143+
## Scripts
144+
145+
```bash
146+
# Generate Prisma client
147+
npm run generate
148+
149+
# Run seeding
150+
npm run seed
151+
```
152+
153+
## Output
154+
155+
Successful seeding shows:
156+
```
157+
🧹 Clearing existing data...
158+
✅ Existing data cleared
159+
160+
🏘️ Creating Calgary neighborhoods...
161+
✅ Created 10 neighborhoods
162+
163+
👥 Creating users...
164+
✨ Created demo user: Sarah Chen
165+
✅ Created 3 city officials
166+
✅ Created 16 citizen users
167+
✅ Total users created: 20
168+
169+
🎯 Creating challenges...
170+
✅ Created 5 active challenges
171+
172+
🚨 Creating civic issues...
173+
✅ Created 20 civic issues
174+
- Critical: 4
175+
- High: 8
176+
- Medium: 5
177+
- Low: 3
178+
179+
🚴 Creating user activities...
180+
✅ Created 14 activities for Sarah Chen
181+
✅ Created activities for 19 other users
182+
✅ Total activities created: 160
183+
184+
🏆 Assigning users to challenges...
185+
✅ Created 23 user-challenge assignments
186+
187+
🎉 Database seeding complete!
188+
```
189+
190+
## For Demo Purposes
191+
192+
### Citizen Flow Demo (Sarah Chen)
193+
1. Login: sarah@civicpulse.ca / password123
194+
2. Check leaderboard position (silver rank, 850 points)
195+
3. View active challenges (2 in progress)
196+
4. See recent activities (14 sustainable trips)
197+
5. Report new pothole issue (similar to existing one)
198+
199+
### City Dashboard Demo (Alex Park)
200+
1. Login: alex.park@calgary.ca / password123
201+
2. View all issues by priority
202+
3. Filter by department (Public Works)
203+
4. See critical issues requiring immediate attention
204+
5. Review issue details and assign crews
205+
206+
### Leaderboard
207+
Top users for competitive display:
208+
1. Marcus Johnson - 2100 points (platinum)
209+
2. Priya Sharma - 1450 points (gold)
210+
3. Casey Wong - 1200 points (gold)
211+
4. David Kim - 1150 points (gold)
212+
5. Emma Rodriguez - 920 points (silver)
213+
6. Sarah Chen - 850 points (silver) ← Demo user
214+
215+
## Data Integrity
216+
217+
- All users have hashed passwords (bcrypt, 10 rounds)
218+
- Neighborhoods properly linked to users
219+
- Issues linked to users with valid categories/priorities
220+
- Activities linked to users with realistic carbon calculations
221+
- Challenge assignments with proper timestamps
222+
- No orphaned records

0 commit comments

Comments
 (0)