I have no idea where CodeImportResult rows get created and am not familiar with the tests, so I doubt it is easier for me to do.
I think all that requires being done is doing 'codeimport.log_file.expires = now + timedelta(days=60)' after creating the codeimport object.
Or if you really do want to ensure preservation of the 'last N', do the
following after creating a codeimport:
store.execute("""
UPDATE LibraryFileAlias
SET expires = CURRENT_TIMESTAMP AT TIME ZONE 'UTC' + interval '60 days'
FROM CodeImport
WHERE
LibraryFileAlias.id = CodeImport.log_file
AND expires IS NULL
AND CodeImport.branch = %s
AND CodeImport.id NOT IN (
SELECT id
FROM CodeImport
WHERE branch = %s
ORDER BY id DESC
LIMIT %s)
""" % (codeimport.branch, codeimport.branch, N))
Oh - and me doing the equivalent manually for all the historical records.
I have no idea where CodeImportResult rows get created and am not familiar with the tests, so I doubt it is easier for me to do.
I think all that requires being done is doing 'codeimport. log_file. expires = now + timedelta(days=60)' after creating the codeimport object.
Or if you really do want to ensure preservation of the 'last N', do the
following after creating a codeimport:
store.execute(""" Alias.id = CodeImport.log_file
UPDATE LibraryFileAlias
SET expires = CURRENT_TIMESTAMP AT TIME ZONE 'UTC' + interval '60 days'
FROM CodeImport
WHERE
LibraryFile
AND expires IS NULL
AND CodeImport.branch = %s
AND CodeImport.id NOT IN (
SELECT id
FROM CodeImport
WHERE branch = %s
ORDER BY id DESC
LIMIT %s)
""" % (codeimport.branch, codeimport.branch, N))
Oh - and me doing the equivalent manually for all the historical records.