{
  "app": {
    "name": "Mokabla",
    "url": "https://www.mokabla.com",
    "description": "Real interview questions from companies in Egypt, organised by company. Access is sold per company for 30 days."
  },
  "page": {
    "kind": "question",
    "title": "Question · trip-occupancy-sql",
    "humanPath": "/en/c/swvl/trip-occupancy-sql",
    "humanOnly": false
  },
  "identity": {
    "class": "declared",
    "agent": "ClaudeBot",
    "operator": "Anthropic",
    "verified": false,
    "reason": "The user agent is ClaudeBot (Anthropic), which identifies itself as an AI agent.",
    "signals": [
      "Known agent user agent"
    ],
    "claimable": false
  },
  "state": {
    "question": {
      "slug": "trip-occupancy-sql",
      "title": "Trip Occupancy Query",
      "difficulty": "medium",
      "tags": [
        "sql",
        "technical",
        "backend",
        "data-eng"
      ],
      "is_free": true,
      "locked": false,
      "frequency": 1,
      "last_reported_at": "2026-08-20T11:55:03.203701Z",
      "url": "https://www.mokabla.com/en/c/swvl/trip-occupancy-sql",
      "agent": {
        "page": "https://www.mokabla.com/agent/en/c/swvl/trip-occupancy-sql",
        "question": "https://www.mokabla.com/agent/_call/get_question?company=swvl&question=trip-occupancy-sql"
      },
      "company": {
        "slug": "swvl",
        "name_en": "Swvl"
      },
      "body_md": "## Problem\nGiven the tables below, write one query that returns, for every route, the number of trips it ran in the\nlast 30 days, its average occupancy percentage (booked seats ÷ capacity, computed per trip then averaged),\nand a boolean `underused` for routes averaging below 40%. Cancelled bookings must not count. Routes with\nno trips in the window must still appear with `trips = 0`.\n\n```\nroutes(id, name, city)\ntrips(id, route_id, capacity, departed_at)\nbookings(id, trip_id, status)   -- status in ('confirmed', 'cancelled', 'no_show')\n```\n\n## Examples\n**Example 1**, Route \"Maadi → Smart Village\" ran two trips: trip 10 (capacity 20, 15 confirmed,\n2 cancelled) and trip 11 (capacity 20, 4 confirmed). Per-trip occupancy 75% and 20% → `avg_occupancy =\n47.5`, `underused = false`.\n\n**Example 2**, Route \"6th Oct → Zamalek\" only has trips from 60 days ago → `trips = 0`,\n`avg_occupancy = NULL`, `underused = false`.\n\n## Constraints\n- Postgres 14. `no_show` counts as a booked seat (the seat was taken)\n- Round occupancy to 1 decimal place\n- Order by `avg_occupancy` ascending, NULLs last\n\n## What they look for\nThe date filter in the join's `ON` clause or in a pre-filtered CTE (not the outer `WHERE`) so empty routes\nsurvive the LEFT JOIN, aggregating at trip level before averaging (averaging one ratio across all bookings\nskews toward busy trips), and guarding capacity 0. Follow-up: making it fast on 50M bookings, a partial\nindex on `bookings(trip_id) WHERE status <> 'cancelled'` and partitioning `trips` by month.",
      "follow_ups_md": "- Same report but per route per weekday.\n- How would you compute this incrementally every hour instead of scanning 30 days?"
    },
    "paid": false,
    "access": "Question bodies are paid content: a person buys 30 days of access per company (200 EGP or 200 points) in the human app. Agents get titles, tags and difficulty; bodies only for free questions."
  },
  "actions": [
    {
      "name": "get_question",
      "description": "One question with its body. Bodies are paid content unless the question is free.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "question": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/get_question?company=swvl&question=trip-occupancy-sql",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "list_questions",
      "description": "The questions reported at a company: titles, tags, difficulty, whether each is free or paid.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "page": "number?"
      },
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=swvl",
      "ready": true,
      "missing": []
    },
    {
      "name": "buy_access",
      "description": "Buy 30 days of access to a company.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "payment",
      "input": {
        "company": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/buy_access?company=swvl",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "post_comment",
      "description": "Comment on a question.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "write",
      "input": {
        "question": "string",
        "text": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/post_comment?question=trip-occupancy-sql",
      "ready": false,
      "missing": [
        "text"
      ],
      "humanPath": "https://www.mokabla.com/en/companies"
    }
  ],
  "navigate": [
    {
      "label": "This question, as data (free questions only)",
      "href": "https://www.mokabla.com/agent/_call/get_question?company=swvl&question=trip-occupancy-sql"
    },
    {
      "label": "All questions at this company",
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=swvl"
    },
    {
      "label": "The company page",
      "href": "https://www.mokabla.com/agent/en/c/swvl"
    },
    {
      "label": "Trip Occupancy Query · page",
      "href": "https://www.mokabla.com/agent/en/c/swvl/trip-occupancy-sql"
    }
  ],
  "notices": [
    {
      "severity": "info",
      "message": "This classification is final for the session: it came from a strong signal, not a guess. The human pages are not served to agents."
    },
    {
      "severity": "info",
      "message": "Unverified agents are read-only. Signed requests (Web Bot Auth) are the path to write access."
    }
  ],
  "meta": {
    "requestId": "ag_49aa95e48003",
    "policyVersion": "mokabla-2026-11-03",
    "generatedAt": "2026-11-03T17:38:18.364Z",
    "jsonUrl": "https://www.mokabla.com/agent/en/c/swvl/trip-occupancy-sql?format=json",
    "manifestUrl": "https://www.mokabla.com/.well-known/agentgate.json",
    "humanUrl": "https://www.mokabla.com/en/c/swvl/trip-occupancy-sql",
    "humanClaimUrl": "https://www.mokabla.com/agent/_claim/human?to=%2Fen%2Fc%2Fswvl%2Ftrip-occupancy-sql"
  }
}