<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def confirm(self, batch_id=None, filename=None):
 """Flags the batch as confirmed by updating confirmation_datetime on the history model for this batch. """

        if batch_id or filename:
            export_history = self.history_model.objects.using(self.using).filter(
                Q(batch_id=batch_id) | Q(filename=filename),
                sent=True,
                confirmation_code__isnull=True,
            )
        else:
            export_history = self.history_model.objects.using(self.using).filter(
                sent=True, confirmation_code__isnull=True
            )
        if export_history.count() == 0:
            raise ConfirmationError(
                "Nothing to do. No history of sent and unconfirmed files"
            )
        else:
            confirmation_code = ConfirmationCode()
            export_history.update(
                confirmation_code=confirmation_code.identifier,
                confirmation_datetime=get_utcnow(),
            )
        return confirmation_code.identifier