'This will record the results from the import, and change the
status of the upload job
@todo: parameter descriptions?
@todo: report errors in referenced records, too'

def _update_upload_job(self, upload_id):

    resource = self.request.resource
    db = current.db
    totalPreDelete = len(self.importDetails['preDelete'])
    totalPreImport = len(self.importDetails['preImportTree'])
    totalIgnored = (totalPreDelete - totalPreImport)
    if (resource.error_tree is None):
        totalErrors = 0
    else:
        totalErrors = len(resource.error_tree.findall(("resource[@name='%s']" % resource.tablename)))
    totalRecords = (totalPreImport - totalErrors)
    if (totalRecords < 0):
        totalRecords = 0
    query = (self.upload_table.id == upload_id)
    db(query).update(summary_added=totalRecords, summary_error=totalErrors, summary_ignored=totalIgnored, status=3)
    db.commit()
    return (totalRecords, totalErrors, totalIgnored)
