docstr: Add durations at every epoch to the db
docstr_tok: ["Add","durations","at","every","epoch","to","the","db"]
code: def add_epoch_duration(self, value, epoch=None):
      """
      Add durations at every epoch to the db
      """
  
      if not isinstance(self.experiment_obj.durations, dict):
          self.experiment_obj.durations = {
              "duration": {},
              "tag_list": [],
          }
  
      duration_keys = value.keys()
      existing_tag_list = self.experiment_obj.durations["tag_list"]
  
      for duration in duration_keys:
          if duration not in existing_tag_list:
              existing_tag_list.append(duration)
              self.experiment_obj.durations["duration"][duration] = [
                  {"epoch": epoch, "value": value[duration]}
              ]
          else:
              self.experiment_obj.durations["duration"][duration] += [
                  {"epoch": epoch, "value": value[duration]}
              ]
  
      self.experiment_obj.save()
  
imports: import json
  from settings import settings
  from datetime import datetime
  from django.utils import timezone
  from django.contrib.auth.models import AnonymousUser
  from channels.db import database_sync_to_async
  from channels.auth import login
  from channels.generic.websocket import AsyncWebsocketConsumer
  from modelchimp.models.membership import Membership
  from modelchimp.models.experiment import Experiment
  from modelchimp.enum import ClientEvent, ExperimentStatus
label_desc: Use image node_id 5 for calling the TrackerConsumer obj's underlying member method code with example usage: obj.add_epoch_duration(value, epoch) without return types