probo icon indicating copy to clipboard operation
probo copied to clipboard

Use files table everywhere

Open SachaProbo opened this issue 1 year ago • 7 comments

Use a common files tables/model for all S3 file related logic and refacto url generation and upload.

SachaProbo avatar Aug 13 '25 08:08 SachaProbo

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.go file 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 ?

johndoedinomis avatar Sep 26 '25 09:09 johndoedinomis

We already have a function: generate_gid(decode_base64_unpadded(TENANT_ID), ENTITY_TYPE)

SachaProbo avatar Sep 29 '25 07:09 SachaProbo

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 ?

johndoedinomis avatar Sep 30 '25 12:09 johndoedinomis

The url is a specific field for evidence that don't have a file but use directly an external url as the reference.

SachaProbo avatar Sep 30 '25 12:09 SachaProbo

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 :

Image

If we should only keep the link in the evidences.url field, then I will refactor the front and migrations accordingly.

johndoedinomis avatar Sep 30 '25 14:09 johndoedinomis

We should store the evidence in files.

SachaProbo avatar Oct 02 '25 13:10 SachaProbo

Merged in https://github.com/getprobo/probo/commit/ff7ba08fc1158739be728d3b7c9aa470a2174174

SachaProbo avatar Oct 08 '25 16:10 SachaProbo