Repository challenges
Correct a misleading conversion dashboard
Debugging · Intermediate · Data analytics · 35 minutes
Engineering ticket
The overview dashboard averages daily conversion rates even when daily traffic varies. Implement overview(days): each day has integer visitors and conversions, with 0 <= conversions <= visitors. Return the overall conversions / visitors ratio rounded to six decimal places. If total visitors is zero, return 0.0. Write a short explanation in DASHBOARD.md about why an unweighted daily average misrepresents this metric.
Review rubric
- Correctness on documented inputs
- Tests and edge cases
- Clear explanation of trade-offs
Reading the ticket and starter files is public. Sign in to save edits, run tests and submit evidence. Code-review quality requires human review.
Starter repository
README.md
# InferenceAI engineering lab Read the ticket, inspect the files, reproduce the issue and implement the contract. Run visible tests while working. Submit checks protected cases. Explain your changes and limitations.
DASHBOARD.md
# Metric definition # Why weighting matters
dashboard.py
def overview(days):
if not days:
return 0.0
return round(sum(d["conversions"]/d["visitors"] if d["visitors"] else 0 for d in days)/len(days), 6)
tests/test_dashboard.py
import unittest
from dashboard import *
class ContractTest(unittest.TestCase):
def test_example(self):
self.assertEqual(overview([{"visitors":1,"conversions":1},{"visitors":99,"conversions":0}]), 0.01)