socek

Untitled

Dec 30th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. class EndpointLog(Model, ModelLoggerMixing):
  2.  
  3.     id = UUIDField(auto=True, primary_key=True)
  4.     when_created = DateTimeField(default=get_default_time, db_index=True)
  5.     site_id = CharField(
  6.         max_length=24,
  7.         db_column='site',
  8.         db_index=True,
  9.     )
  10.     session_id = UUIDField()
  11.     values = JSONField()
  12.     name = CharField(max_length=20)
  13.     ended_with_success = BooleanField(default=False)
  14.  
  15. # Co potrzebuję:
  16. # Filtrowanie po site_id (widok będzie pokazywał tylko 1 site na raz).
  17. # Groupowanie po name.
  18. # Wyliczenie ile w danym name było ended_with_success==True a ile ended_with_success==False.
  19.  
  20. #chyba się udało:
  21. EndpointLog.objects.values('name', 'ended_with_success').annotate(Count('id'))
Advertisement
Add Comment
Please, Sign In to add comment