Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions queueless_backend/mock_api/management/commands/seed_mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,30 @@ def add_arguments(self, parser):
action="store_true",
help="Delete existing queue entries for seeded institutions first.",
)
parser.add_argument(
"--flush",
action="store_true",
help="Delete ALL institutions and queue entries before seeding.",
)
parser.add_argument(
"--close-count",
type=int,
default=0,
help="Number of institutions to set as CLOSED for simulation.",
)

def handle(self, *args, **options):
skip_queues = options["skip_queues"]
min_queue = options["min_queue"]
max_queue = options["max_queue"]
reset_queues = options["reset_queues"]
flush = options["flush"]
close_count = options["close_count"]

if flush:
self.stdout.write(self.style.WARNING("Flushing all data..."))
QueueEntry.objects.all().delete()
Institution.objects.all().delete()

if min_queue < 0 or max_queue < 0:
self.stderr.write(self.style.ERROR("Queue limits cannot be negative."))
Expand Down Expand Up @@ -121,6 +139,16 @@ def handle(self, *args, **options):
else:
updated_count += 1

# Handle closing random institutions
if close_count > 0:
to_close = random.sample(
seeded_institutions, min(close_count, len(seeded_institutions))
)
for inst in to_close:
inst.status = Institution.Status.CLOSED
inst.save()
self.stdout.write(f"Closed {len(to_close)} institutions for simulation.")

self.stdout.write(
self.style.SUCCESS(
"Institutions seeded. "
Expand Down
42 changes: 40 additions & 2 deletions queueless_backend/queueless_backend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ def landing_page(request):
background: var(--bg);
background-image: var(--gradient-bg);
color: var(--text);
height: 100vh;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
overflow: hidden;
padding: 5rem 1.5rem 2rem 1.5rem;
}}
.nav {{
position: absolute;
Expand Down Expand Up @@ -133,6 +133,7 @@ def landing_page(request):
gap: 1rem;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}}
.btn {{
padding: 1rem 2rem;
Expand Down Expand Up @@ -200,6 +201,43 @@ def landing_page(request):
);
border-radius: 50%;
}}
@media (max-width: 640px) {{
.stats {{
gap: 2rem;
flex-wrap: wrap;
}}
h1 {{
font-size: 2.5rem;
}}
.nav {{
padding: 1.5rem;
}}
}}
@media (max-width: 480px) {{
.cta-group {{
flex-direction: column;
width: 100%;
}}
.btn {{
width: 100%;
text-align: center;
}}
.stats {{
gap: 1.5rem;
flex-direction: column;
align-items: center;
text-align: center;
}}
.stat-item {{
text-align: center;
}}
h1 {{
font-size: 2.25rem;
}}
p {{
font-size: 1.1rem;
}}
}}
</style>
</head>
<body>
Expand Down
52 changes: 52 additions & 0 deletions seed-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Seed Data Management

This document provides instructions on how to use the custom management commands to seed and manage mock data for the QueueLess Backend.

## 1. Seeding Mock Data
The `seed_mock_data` command is used to populate the database with mock institutions and queue entries for simulation.

### Basic Seeding
Populate the database with default institutions and a random number of queue entries:
```bash
python manage.py seed_mock_data
```

### Resetting to a Clean State
If you want to clear all existing data (institutions and queues) and start fresh from Ticket #1:
```bash
python manage.py seed_mock_data --flush
```

### Simulating Closed Institutions
To randomly set a specific number of institutions to `CLOSED` status for testing "Unavailable" states:
```bash
python manage.py seed_mock_data --close-count 3
```

## 2. Advanced Options

| Argument | Type | Default | Description |
|----------|------|---------|-------------|
| `--flush` | flag | N/A | Deletes ALL institutions and queue entries before seeding. |
| `--close-count` | int | 0 | Number of institutions to randomly set as CLOSED. |
| `--min-queue` | int | 5 | Minimum random queue entries per institution. |
| `--max-queue` | int | 12 | Maximum random queue entries per institution. |
| `--skip-queues` | flag | N/A | Create institutions only, skip generating queue entries. |
| `--reset-queues`| flag | N/A | Deletes queue entries for seeded institutions only (keeps non-seeded ones). |

## 3. Example Scenarios

**Scenario A: High Traffic Simulation**
```bash
python manage.py seed_mock_data --min-queue 50 --max-queue 100
```

**Scenario B: Limited Availability Test**
```bash
python manage.py seed_mock_data --flush --close-count 5
```

**Scenario C: Empty Institutions Only**
```bash
python manage.py seed_mock_data --flush --skip-queues
```
Loading