Ejemplo n.º 1
0
 def populate_from_df(self, df):
     send_ids = set(df['SendID'])
     for send_id in send_ids:
         try:
             sj = SendJob.objects.get(SendID=send_id,
                                      dependent_reports_up_to_date=True)
         except SendJob.DoesNotExist:
             continue
         sj.dependent_reports_up_to_date = False
         sj.save()
     # assumes a csv has entire records from a day.
     event = df['EventType'].iloc[0]
     event_records = self.filter(EventType=event)
     dates = {d.date() for d in df['EventDate']}
     for date in dates:
         old_records = event_records.filter(EventDate__contains=date)
         old_records.delete()
     plp.to_django(df, self.model)
Ejemplo n.º 2
0
 def _populate_from_df_remove_old(self, df, unique_element):
     ids = set(df[unique_element])
     kwargs = {'{}__in'.format(unique_element): ids}
     old_records = self.filter(**kwargs)
     old_records.delete()
     plp.to_django(df, self.model)