Skip to content

Latest commit

 

History

History
102 lines (78 loc) · 3 KB

File metadata and controls

102 lines (78 loc) · 3 KB

Insomnia Instructions for Populating Database

Setup Instructions

  1. Import the API Collection (if available):

    • Import the onboarding_api_insomnia.json file into Insomnia
    • Set the base URL environment variable to: http://127.0.0.1:8000/api
  2. Create a New Request:

    • Method: POST
    • URL: {{base_url}}/candidates/
    • Headers: Content-Type: application/json
  3. Authentication (if required):

    • Add any necessary authentication headers

How to Use the JSON Data

The candidates.json file contains 50 candidate entries formatted for the Django REST API. Each entry includes:

Required Fields:

  • name: Full name of the candidate
  • email: Unique email address
  • phone: Phone number (15 chars max)
  • age: Integer between 18-25
  • address: Text address
  • skills: Comma-separated string of skills
  • twelfth_pass: Boolean (true for all entries)
  • family_income: Decimal (under 3 lakh for eligibility)
  • not_working: Boolean (true for all entries)

Sample API Call:

Method: POST URL: http://127.0.0.1:8000/api/candidates/ Body (JSON):

{
  "name": "Aarav Sharma",
  "email": "aarav.sharma@example.com",
  "phone": "+91-9876543210",
  "age": 22,
  "skills": "Python, Data Analysis",
  "address": "Delhi, India",
  "twelfth_pass": true,
  "family_income": 250000.00,
  "not_working": true
}

Bulk Import Options

Option 1: Individual Requests

  • Copy each JSON object from candidates.json
  • Paste into Insomnia request body
  • Send 50 separate POST requests

Option 2: Scripted Import (Recommended)

Create a simple Python script to automate the process:

import requests
import json

API_URL = "http://127.0.0.1:8000/api/candidates/"

with open('candidates.json', 'r') as f:
    candidates = json.load(f)

for candidate in candidates:
    response = requests.post(API_URL, json=candidate)
    if response.status_code == 201:
        print(f"✓ Created candidate: {candidate['name']}")
    else:
        print(f"✗ Failed to create {candidate['name']}: {response.text}")

Option 3: Django Management Command

Create a custom Django management command for bulk import.

Verification

After importing, verify the data:

  1. Check Count: GET http://127.0.0.1:8000/api/candidates/ should return 50 candidates
  2. Eligibility Check: POST to /api/candidates/{id}/validate_eligibility/ for each candidate
  3. Dashboard: Check the frontend dashboard at http://localhost:3002 (or your Next.js port)

Data Characteristics

  • Age Range: 18-25 years
  • Income Range: ₹2,15,000 - ₹2,95,000 (all under ₹3 lakh)
  • Locations: 50 different Indian cities
  • Skills: Diverse technology and domain skills
  • All Eligible: All candidates meet MagicBus foundation criteria

Troubleshooting

  • 400 Bad Request: Check required fields and data types
  • 500 Server Error: Ensure Django server is running
  • Unique Constraint: Emails must be unique
  • Validation Errors: Check age (18-25) and income (< 3 lakh) constraints