Use files table everywhere
Use a common files tables/model for all S3 file related logic and refacto url generation and upload.
I am working on it, it seems that the tables impacted are reports and evidences.
For the migration we should generate gid for the file registered in those tables in order to create their equivalent in the filestable, I vibe came up with a postgresql function that generates new gid but I want it to be properly tested, I can either :
- run some manual tests and call it a day
- integrate the testing of the function in a
gid_test.gofile and make it run against a postgresql test database, any preferred means to do so ? I've seen that it might be convenient to run the tests against a postgres container spwaned by the testcontainers lib, is it fine ?
We already have a function: generate_gid(decode_base64_unpadded(TENANT_ID), ENTITY_TYPE)
Concerning the evidences model, the UI indicates that it will store the url if it is a link as a .uri file containing the URL, but there is a url field in the table that I think is aimed at storing this link as done in (s EvidenceService) Fulfill but it is stored as a file in (s EvidenceService) UploadTaskEvidence and (s EvidenceService) UploadMeasureEvidence. Should we store the evidence link in evidences.url or in files and refactor the front / graphql accordingly ?
The url is a specific field for evidence that don't have a file but use directly an external url as the reference.
Yes I get it, we have either a file evidence type or a link evidence type. But it can be both of those types for a link type, in the aforementioned functions, and as illustrated in this snippet in the front :
export function fileType(__: (s: string) => string, info: FileInfo): string {
if (
info.type !== "FILE" ||
(info.mimeType !== "text/uri-list" && info.mimeType !== "text/uri")
) {
return __("Document");
}
return __("Link");
}
and this screenshot :
If we should only keep the link in the evidences.url field, then I will refactor the front and migrations accordingly.
We should store the evidence in files.
Merged in https://github.com/getprobo/probo/commit/ff7ba08fc1158739be728d3b7c9aa470a2174174