File size: 9,435 Bytes
453520f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Database seeding script for EVG Ultimate Team.

Populates the database with the 13 participants and sample challenges
for Paul's bachelor party.

Run this script once to initialize the database with test data.

Usage:
    python seed_database.py
"""

from app.database import SessionLocal, init_db, reset_db
from app.models import Participant, Challenge, ChallengeType, ChallengeStatus
from app.utils.logger import logger


def seed_participants(db):
    """
    Seed the database with all 13 participants.

    Participants (from the user's specification):
    1. Paul C. - The groom
    2. Clément P. - Admin and wedding witness
    3. Paul J. - Wedding witness
    4. Hugo F. - Wedding witness
    5. Théo C. - Groom's brother and wedding witness
    6. Antonin M. - Groom's cousin and wedding witness
    7. Philippe C. - Groom's cousin and wedding witness
    8. Lancelot M. - Wedding witness
    9. Vianney D.
    10. Thomas S.
    11. Martin L.
    12. Guillaume V.
    13. Adrien M.
    """
    logger.info("Seeding participants...")

    participants_data = [
        {"name": "Paul C.", "is_groom": True, "avatar_url": None},
        {"name": "Clément P.", "is_groom": False, "avatar_url": None},  # Admin
        {"name": "Paul J.", "is_groom": False, "avatar_url": None},
        {"name": "Hugo F.", "is_groom": False, "avatar_url": None},
        {"name": "Théo C.", "is_groom": False, "avatar_url": None},
        {"name": "Antonin M.", "is_groom": False, "avatar_url": None},
        {"name": "Philippe C.", "is_groom": False, "avatar_url": None},
        {"name": "Lancelot M.", "is_groom": False, "avatar_url": None},
        {"name": "Vianney D.", "is_groom": False, "avatar_url": None},
        {"name": "Thomas S.", "is_groom": False, "avatar_url": None},
        {"name": "Martin L.", "is_groom": False, "avatar_url": None},
        {"name": "Guillaume V.", "is_groom": False, "avatar_url": None},
        {"name": "Adrien M.", "is_groom": False, "avatar_url": None},
    ]

    for data in participants_data:
        participant = Participant(
            name=data["name"],
            is_groom=data["is_groom"],
            avatar_url=data["avatar_url"],
            total_points=0,
            current_packs={"bronze": 0, "silver": 0, "gold": 0, "ultimate": 0}
        )
        db.add(participant)

    db.commit()
    logger.info(f"✓ Created {len(participants_data)} participants")


def seed_challenges(db):
    """
    Seed the database with sample challenges based on CLAUDE.md specifications.
    """
    logger.info("Seeding challenges...")

    challenges_data = [
        # Individual Challenges (20-50 pts)
        {
            "title": "Convince a stranger you're a Red Bull sales rep",
            "description": "Approach a stranger and successfully convince them you work for Red Bull. Must last at least 2 minutes.",
            "type": ChallengeType.INDIVIDUAL,
            "points": 30,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Win a 1v1 FIFA match against Paul",
            "description": "Challenge Paul to a FIFA match and win. Best of 3 games.",
            "type": ChallengeType.INDIVIDUAL,
            "points": 50,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Complete a rugby transformation",
            "description": "Score a try in the touch rugby game with proper technique.",
            "type": ChallengeType.INDIVIDUAL,
            "points": 40,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Finish first in go-kart racing",
            "description": "Win the go-kart race against all other participants.",
            "type": ChallengeType.INDIVIDUAL,
            "points": 50,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Give a 2-minute speech about why Paul is the best groom",
            "description": "Deliver an impromptu 2-minute speech praising Paul. Must be heartfelt and entertaining.",
            "type": ChallengeType.INDIVIDUAL,
            "points": 35,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Order a shot mimicking Paul's accent",
            "description": "Successfully order a shot at the bar using Paul's accent. Bartender must not notice.",
            "type": ChallengeType.INDIVIDUAL,
            "points": 25,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Pitch an absurd item to a stranger",
            "description": "Use Paul's commercial skills to pitch a ridiculous product to a stranger (e.g., invisible socks). Must last 2 minutes.",
            "type": ChallengeType.INDIVIDUAL,
            "points": 30,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Negotiate a discount at the restaurant",
            "description": "Successfully negotiate at least a 10% discount on the bill using your charm.",
            "type": ChallengeType.INDIVIDUAL,
            "points": 45,
            "status": ChallengeStatus.PENDING
        },

        # Team Challenges (100 pts shared)
        {
            "title": "Win the padel tournament",
            "description": "Your team must win the padel tournament on Saturday afternoon.",
            "type": ChallengeType.TEAM,
            "points": 100,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Win the football match",
            "description": "Your team must win the football match on Saturday afternoon.",
            "type": ChallengeType.TEAM,
            "points": 100,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Finish champagne bottle under 5 minutes",
            "description": "Your team of 4 must finish a full champagne bottle in under 5 minutes.",
            "type": ChallengeType.TEAM,
            "points": 100,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Complete a 5-person karaoke",
            "description": "Get 5 people to perform a full karaoke song together. Must be a classic.",
            "type": ChallengeType.TEAM,
            "points": 100,
            "status": ChallengeStatus.PENDING
        },

        # Secret Challenges (50-100 pts)
        {
            "title": "Make Paul laugh during dinner",
            "description": "SECRET: Next person to make Paul genuinely laugh during dinner wins. Admin will reveal this at dinner.",
            "type": ChallengeType.SECRET,
            "points": 50,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Spot the reference",
            "description": "SECRET: First person to notice and mention the hidden Toulouse Stade reference wins.",
            "type": ChallengeType.SECRET,
            "points": 75,
            "status": ChallengeStatus.PENDING
        },
        {
            "title": "Midnight champion",
            "description": "SECRET: Last person awake on Friday night wins bonus points.",
            "type": ChallengeType.SECRET,
            "points": 100,
            "status": ChallengeStatus.PENDING
        },

        # Penalties (would be created by admin as needed)
        # These are just examples - admin creates them on the fly
    ]

    for data in challenges_data:
        challenge = Challenge(
            title=data["title"],
            description=data["description"],
            type=data["type"],
            points=data["points"],
            status=data["status"]
        )
        db.add(challenge)

    db.commit()
    logger.info(f"✓ Created {len(challenges_data)} challenges")


def main():
    """
    Main seeding function.

    WARNING: This will reset the entire database!
    """
    logger.info("=" * 80)
    logger.info("EVG ULTIMATE TEAM - Database Seeding")
    logger.info("=" * 80)
    logger.warning("This will RESET the database and create fresh data!")
    logger.info("")

    # Confirm before proceeding
    response = input("Continue? (yes/no): ")
    if response.lower() not in ['yes', 'y']:
        logger.info("Seeding cancelled")
        return

    # Reset database (drop all tables and recreate)
    logger.info("\nResetting database...")
    reset_db()

    # Create database session
    db = SessionLocal()

    try:
        # Seed data
        seed_participants(db)
        seed_challenges(db)

        logger.info("")
        logger.info("=" * 80)
        logger.info("✓ Database seeding completed successfully!")
        logger.info("=" * 80)
        logger.info("")
        logger.info("Summary:")
        logger.info("  - 13 participants created (Paul C. is the groom)")
        logger.info("  - 15 sample challenges created")
        logger.info("")
        logger.info("Admin credentials (from .env):")
        logger.info("  Username: clement")
        logger.info("  Password: evg2026_admin")
        logger.info("")
        logger.info("You can now start the backend server:")
        logger.info("  python -m app.main")
        logger.info("  OR")
        logger.info("  uvicorn app.main:app --reload")
        logger.info("=" * 80)

    except Exception as e:
        logger.error(f"Error during seeding: {str(e)}")
        db.rollback()
        raise
    finally:
        db.close()


if __name__ == "__main__":
    main()