parameters: (cls, flow_id)
return_statement: return FlowRevision.objects.filter(flow=flow_id, created_on__lt=cutoff).exclude(id__in=keepers).delete()[0]
docstring: Trims the revisions for the passed in flow.
  
          Our logic is:
           * always keep last 25 revisions
           * for any revision beyond those, collapse to first revision for that day
  
          :param flow: the id of the flow to trim revisions for
          :return: the number of trimmed revisions
docstring_summary: Trims the revisions for the passed in flow.
docstring_tokens: Trims the revisions for the passed in flow .
function: def trim_for_flow(cls, flow_id):
          """
          Trims the revisions for the passed in flow.
  
          Our logic is:
           * always keep last 25 revisions
           * for any revision beyond those, collapse to first revision for that day
  
          :param flow: the id of the flow to trim revisions for
          :return: the number of trimmed revisions
          """
          # find what date cutoff we will use for "25 most recent"
          cutoff = FlowRevision.objects.filter(flow=flow_id).order_by("-created_on")[24:25]
  
          # fewer than 25 revisions
          if not cutoff:
              return 0
  
          cutoff = cutoff[0].created_on
  
          # find the ids of the first revision for each day starting at the cutoff
          keepers = (
              FlowRevision.objects.filter(flow=flow_id, created_on__lt=cutoff)
              .annotate(created_date=TruncDate("created_on"))
              .values("created_date")
              .annotate(max_id=Max("id"))
              .values_list("max_id", flat=True)
          )
  
          # delete the rest
          return FlowRevision.objects.filter(flow=flow_id, created_on__lt=cutoff).exclude(id__in=keepers).delete()[0]
function_tokens: def trim_for_flow ( cls , flow_id ) : # find what date cutoff we will use for "25 most recent" cutoff = FlowRevision . objects . filter ( flow = flow_id ) . order_by ( "-created_on" ) [ 24 : 25 ] # fewer than 25 revisions if not cutoff : return 0 cutoff = cutoff [ 0 ] . created_on # find the ids of the first revision for each day starting at the cutoff keepers = ( FlowRevision . objects . filter ( flow = flow_id , created_on__lt = cutoff ) . annotate ( created_date = TruncDate ( "created_on" ) ) . values ( "created_date" ) . annotate ( max_id = Max ( "id" ) ) . values_list ( "max_id" , flat = True ) ) # delete the rest return FlowRevision . objects . filter ( flow = flow_id , created_on__lt = cutoff ) . exclude ( id__in = keepers ) . delete ( ) [ 0 ]