models.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. """Scientific method lives here!"""
  2. from django.db import models
  3. # Scientific method components:
  4. #
  5. # Question
  6. # Hypothesis
  7. # Prediction
  8. # Experiment(Testing)
  9. # Analysis
  10. class BaseModel(models.Model):
  11. created_at = models.DateTimeField(auto_now_add=True)
  12. updated_at = models.DateTimeField(auto_now=True)
  13. class Meta:
  14. abstract = True
  15. # bad boy
  16. # request --> some view --> some function --> BANG !! ...
  17. # good boy
  18. # request --> some view --> some function --> some other --> response
  19. class Flow(models.Model):
  20. """Abstract representation of steps to be reduced for seeking the root cause"""
  21. pass
  22. class System(models.Model):
  23. """Short name for the environment: "Download manager", "Video player"..."""
  24. name = models.CharField(max_length=255)
  25. class Observation(BaseModel):
  26. """Step of the SM"""
  27. description = models.CharField(max_length=255)
  28. class Hypothesis(BaseModel):
  29. """Proposed explanation for a phenomenon; To be checked"""
  30. proposition = models.CharField(max_length=255)
  31. is_valid = models.NullBooleanField(blank=True, null=True)
  32. class Story(BaseModel):
  33. """Represent the concrete case of debug session.
  34. initial_statement: the origin of the bug -- short line describes what's wrong;
  35. description: what the system looks like?
  36. system: what is the system?
  37. conclusion: detailed explanation why does issue appear;
  38. final_statement: summarized result of investigation
  39. Tip:
  40. Describe the breakage first in Passive Verb Forms, then clarify it in Active form
  41. """
  42. initial_statement = models.CharField(max_length=255)
  43. final_statement = models.CharField(max_length=255, blank=True, null=True)
  44. # TODO: maybe should be named `scope'?
  45. description = models.TextField()
  46. hypotheses = models.ForeignKey(
  47. Hypothesis, on_delete=models.CASCADE, related_name='phenomenon', null=True
  48. )
  49. observation = models.ForeignKey(
  50. Observation, on_delete=models.CASCADE, null=True
  51. )
  52. conclusion = models.TextField(blank=True, null=True)
  53. system = models.ForeignKey(System, on_delete=models.CASCADE)