From 64abdee37438d3711902778b6a6418bf99c9df84 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Wed, 22 Jan 2025 11:30:06 +0100
Subject: [PATCH 01/15] [search] improved basic search query builder, added a
 size param to allow more than 10 results

---
 app/dal/elasticService.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/dal/elasticService.js b/app/dal/elasticService.js
index f7d9b9d..a1e72fd 100644
--- a/app/dal/elasticService.js
+++ b/app/dal/elasticService.js
@@ -72,9 +72,14 @@ async function search({query, sourcesId, scroll_id, advancedQuery}) {
         if (!advancedQuery) {
             queryBuilder = {
                 query: {
+                    size: 10000,
                     query_string: {
                         query: query,
-                        default_operator: "or",
+                        fuzziness: "2",
+                        default_operator: "OR",
+                        analyze_wildcard: true,
+                        lenient: true,
+                        minimum_should_match: "1"
                     },
                 },
             };
-- 
GitLab


From 08911a1586dc6160925a6a5e82ff2e9ef3ea16d8 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Wed, 22 Jan 2025 11:44:27 +0100
Subject: [PATCH 02/15] [search] corrected bug in basic search [chore] removed
 useless debug logs

---
 app/api/search/post.js     | 5 -----
 app/dal/elasticService.js  | 6 +-----
 app/dal/stdFieldService.js | 2 --
 3 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/app/api/search/post.js b/app/api/search/post.js
index c7c9f07..2a3259d 100644
--- a/app/api/search/post.js
+++ b/app/api/search/post.js
@@ -6,7 +6,6 @@ const {search} = require("@/app/dal/elasticService");
 const logger = require("@/app/utils/format");
 
 async function getQueryResultsHandler(ctx) {
-    logger.debug("getQueryResultsHandler");
     const {
         query,
         sourcesId,
@@ -37,13 +36,9 @@ async function getQueryResultsHandler(ctx) {
                     scroll_id,
                     advancedQuery,
                 });
-                logger.debug(`result: ${JSON.stringify(result)}`);
                 let hits = [];
                 for (let record of result?.hits?.hits) {
                     const {_source, _index, _id} = record;
-                    logger.debug(`_source: ${JSON.stringify(_source)}`);
-                    logger.debug(`_index: ${_index}`);
-                    logger.debug(`_id: ${_id}`);
                     hits.push({
                         id: `${_index}_${_id}`,
                         ..._source,
diff --git a/app/dal/elasticService.js b/app/dal/elasticService.js
index a1e72fd..d21681a 100644
--- a/app/dal/elasticService.js
+++ b/app/dal/elasticService.js
@@ -58,8 +58,6 @@ async function bulk(body) {
 
 async function search({query, sourcesId, scroll_id, advancedQuery}) {
     const client = await getClientInstance();
-    logger.debug(`Elasticsearch query: ${JSON.stringify(query)}`);
-    logger.debug("Advanced query: " + advancedQuery);
     if (scroll_id) {
         const {body} = await client.scroll({
             index,
@@ -71,8 +69,8 @@ async function search({query, sourcesId, scroll_id, advancedQuery}) {
         let queryBuilder;
         if (!advancedQuery) {
             queryBuilder = {
+                size: 10000,
                 query: {
-                    size: 10000,
                     query_string: {
                         query: query,
                         fuzziness: "2",
@@ -115,7 +113,6 @@ async function search({query, sourcesId, scroll_id, advancedQuery}) {
                 indices.push(index.index_id);
             }
         }
-        logger.debug(`Searching in indices: ${indices.join(",")}`);
         if (indices.length === 0) {
             logger.error("No indices found for the given sources");
             return {hits: {hits: []}};
@@ -126,7 +123,6 @@ async function search({query, sourcesId, scroll_id, advancedQuery}) {
             body: queryBuilder,
             scroll: "10s",
         });
-        logger.debug(`Search results: ${response.hits.total.value}`);
         return response;
     }
 }
diff --git a/app/dal/stdFieldService.js b/app/dal/stdFieldService.js
index c9d0b09..90a7cb9 100644
--- a/app/dal/stdFieldService.js
+++ b/app/dal/stdFieldService.js
@@ -1,6 +1,5 @@
 "use strict";
 const prisma = require("../../prisma/client");
-const logger = require("@/app/utils/format");
 
 async function getStdFields() {
     const stdFields = await prisma.stdField.findMany({
@@ -84,7 +83,6 @@ async function createOrUpdateStdField({
         throw Error("The request body is empty!");
     }
 
-    logger.debug(default_display_fields);
     // Transform string to bool
     const is_default_display_fields = default_display_fields === "1" ? true : false;
 
-- 
GitLab


From 8d63db1dc111958e06774e4a345b7403a87c7a34 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Wed, 22 Jan 2025 12:09:31 +0100
Subject: [PATCH 03/15] [search] added size param to advanded query builder to
 allow more than 10 results (overrides default value)

---
 app/dal/elasticService.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/dal/elasticService.js b/app/dal/elasticService.js
index d21681a..6d2cba5 100644
--- a/app/dal/elasticService.js
+++ b/app/dal/elasticService.js
@@ -58,6 +58,8 @@ async function bulk(body) {
 
 async function search({query, sourcesId, scroll_id, advancedQuery}) {
     const client = await getClientInstance();
+    // Configure maximum number of results (hits) returned by query
+    const MAXIMUM_HITS_SIZE = 10000;
     if (scroll_id) {
         const {body} = await client.scroll({
             index,
@@ -69,7 +71,7 @@ async function search({query, sourcesId, scroll_id, advancedQuery}) {
         let queryBuilder;
         if (!advancedQuery) {
             queryBuilder = {
-                size: 10000,
+                size: MAXIMUM_HITS_SIZE,
                 query: {
                     query_string: {
                         query: query,
@@ -88,6 +90,7 @@ async function search({query, sourcesId, scroll_id, advancedQuery}) {
                 logger.debug("Advanced query: " + query);
                 query = JSON.parse(query);
                 queryBuilder = {
+                    size: MAXIMUM_HITS_SIZE,
                     query: query
                 };
             } catch (error) {
-- 
GitLab


From bad355bedefa7fb389c90be75421bdafbb75ca32 Mon Sep 17 00:00:00 2001
From: Brett Choquet <brett.choquet@inrae.fr>
Date: Mon, 27 Jan 2025 14:39:27 +0100
Subject: [PATCH 04/15] fix: don't remove roles on startup, it removed roles
 user with cascade

---
 prisma/seed.js | 1 -
 1 file changed, 1 deletion(-)

diff --git a/prisma/seed.js b/prisma/seed.js
index 3d9159e..83ff5a6 100644
--- a/prisma/seed.js
+++ b/prisma/seed.js
@@ -2,7 +2,6 @@ const { PrismaClient } = require("@prisma/client");
 const prisma = new PrismaClient();
 
 async function main() {
-  await prisma.role.deleteMany();
   // Add default roles
   await prisma.role.upsert({
     where: {
-- 
GitLab


From 18bd99ceb966b8789eb0620743e4baf82beb6466 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Thu, 30 Jan 2025 16:08:29 +0100
Subject: [PATCH 05/15] [search] removed scroll search functions

---
 app/api/search/post.js    |  10 ++--
 app/dal/elasticService.js | 111 +++++++++++++++++---------------------
 2 files changed, 54 insertions(+), 67 deletions(-)

diff --git a/app/api/search/post.js b/app/api/search/post.js
index 2a3259d..e3ae74e 100644
--- a/app/api/search/post.js
+++ b/app/api/search/post.js
@@ -10,7 +10,6 @@ async function getQueryResultsHandler(ctx) {
         query,
         sourcesId,
         fieldsId,
-        scroll_id,
         advancedQuery = false,
     } = ctx.request.body;
     if (!query || !sourcesId || !fieldsId) {
@@ -18,22 +17,21 @@ async function getQueryResultsHandler(ctx) {
         if (!query) missingParams.push("query");
         if (!sourcesId) missingParams.push("sourcesId");
         if (!fieldsId) missingParams.push("fieldsId");
-        handleMissingParameters(missingParams, ctx);
+        await handleMissingParameters(missingParams, ctx);
     } else {
         try {
             logger.debug(`query: ${JSON.stringify(query)}`);
             logger.debug(`sourcesId: ${sourcesId}`);
             if (!Array.isArray(sourcesId)) {
-                handleInternalError(new Error("Invalid sourcesId"), ctx);
+                await handleInternalError(new Error("Invalid sourcesId"), ctx);
             }
             const allNumbers = sourcesId.every((id) => typeof id === "number");
             if (!allNumbers) {
-                handleInternalError(new Error("Invalid sourcesId"), ctx);
+                await handleInternalError(new Error("Invalid sourcesId"), ctx);
             } else {
                 const result = await search({
                     query,
                     sourcesId,
-                    scroll_id,
                     advancedQuery,
                 });
                 let hits = [];
@@ -48,7 +46,7 @@ async function getQueryResultsHandler(ctx) {
                 ctx.status = 200;
             }
         } catch (err) {
-            handleInternalError(err, ctx);
+            await handleInternalError(err, ctx);
         }
     }
 }
diff --git a/app/dal/elasticService.js b/app/dal/elasticService.js
index 6d2cba5..17cb667 100644
--- a/app/dal/elasticService.js
+++ b/app/dal/elasticService.js
@@ -56,78 +56,67 @@ async function bulk(body) {
     return true;
 }
 
-async function search({query, sourcesId, scroll_id, advancedQuery}) {
+async function search({query, sourcesId, advancedQuery}) {
     const client = await getClientInstance();
     // Configure maximum number of results (hits) returned by query
     const MAXIMUM_HITS_SIZE = 10000;
-    if (scroll_id) {
-        const {body} = await client.scroll({
-            index,
-            scroll_id,
-            scroll: "10s",
-        });
-        return body;
+    let queryBuilder;
+    if (!advancedQuery) {
+        queryBuilder = {
+            size: MAXIMUM_HITS_SIZE,
+            query: {
+                simple_query_string: {
+                    query: query,
+                    analyze_wildcard: true,
+                    lenient: true,
+                    minimum_should_match: "1"
+                },
+            },
+        };
     } else {
-        let queryBuilder;
-        if (!advancedQuery) {
+        try {
+            // remove trailing and leading whitespaces, tabs, newlines, commas, and semicolons
+            query = query.replace(/(^[,\s\n\t]+)|([,\s\n\t]+$)/g, "");
+            logger.debug("Advanced query: " + query);
+            query = JSON.parse(query);
             queryBuilder = {
                 size: MAXIMUM_HITS_SIZE,
-                query: {
-                    query_string: {
-                        query: query,
-                        fuzziness: "2",
-                        default_operator: "OR",
-                        analyze_wildcard: true,
-                        lenient: true,
-                        minimum_should_match: "1"
-                    },
-                },
+                query: query
             };
-        } else {
-            try {
-                // remove trailing and leading whitespaces, tabs, newlines, commas, and semicolons
-                query = query.replace(/(^[,\s\n\t]+)|([,\s\n\t]+$)/g, "");
-                logger.debug("Advanced query: " + query);
-                query = JSON.parse(query);
-                queryBuilder = {
-                    size: MAXIMUM_HITS_SIZE,
-                    query: query
-                };
-            } catch (error) {
-                logger.error("Invalid query", error);
-                return {hits: {hits: []}};
-            }
-        }
-        let indices = [];
-        for (let sourceId of sourcesId) {
-            const source = await prisma.source.findUnique({
-                where: {
-                    id: +sourceId,
-                },
-                include: {
-                    source_indices: true,
-                },
-            });
-            if (!source) {
-                logger.error(`Source ${sourceId} not found`);
-                continue;
-            }
-            for (let index of source.source_indices) {
-                indices.push(index.index_id);
-            }
-        }
-        if (indices.length === 0) {
-            logger.error("No indices found for the given sources");
+        } catch (error) {
+            logger.error("Invalid query", error);
             return {hits: {hits: []}};
         }
-        logger.debug("Query : " + JSON.stringify(queryBuilder));
-        const response = await client.search({
-            index: indices.join(","),
-            body: queryBuilder,
-            scroll: "10s",
+    }
+    let indices = [];
+    for (let sourceId of sourcesId) {
+        const source = await prisma.source.findUnique({
+            where: {
+                id: +sourceId,
+            },
+            include: {
+                source_indices: true,
+            },
         });
-        return response;
+        if (!source) {
+            logger.error(`Source ${sourceId} not found`);
+            continue;
+        }
+        for (let index of source.source_indices) {
+            indices.push(index.index_id);
+        }
+    }
+    if (indices.length === 0) {
+        logger.error("No indices found for the given sources");
+        return {hits: {hits: []}};
     }
+    logger.debug("Query : " + JSON.stringify(queryBuilder));
+    const response = await client.search({
+        index: indices.join(","),
+        body: queryBuilder,
+        scroll: "10s",
+    });
+    return response;
 }
 
 async function countByIndex(index) {
-- 
GitLab


From 96f81a81ba2637701ebbd13205bee8e27f31a17c Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Thu, 30 Jan 2025 16:11:42 +0100
Subject: [PATCH 06/15] [search] put debug logs back

---
 app/api/search/post.js    | 4 ++++
 app/dal/elasticService.js | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/app/api/search/post.js b/app/api/search/post.js
index e3ae74e..4920999 100644
--- a/app/api/search/post.js
+++ b/app/api/search/post.js
@@ -34,9 +34,13 @@ async function getQueryResultsHandler(ctx) {
                     sourcesId,
                     advancedQuery,
                 });
+                logger.debug(`result: ${JSON.stringify(result)}`);
                 let hits = [];
                 for (let record of result?.hits?.hits) {
                     const {_source, _index, _id} = record;
+                    logger.debug(`_source: ${JSON.stringify(_source)}`);
+                    logger.debug(`_index: ${_index}`);
+                    logger.debug(`_id: ${_id}`);
                     hits.push({
                         id: `${_index}_${_id}`,
                         ..._source,
diff --git a/app/dal/elasticService.js b/app/dal/elasticService.js
index 17cb667..0db7319 100644
--- a/app/dal/elasticService.js
+++ b/app/dal/elasticService.js
@@ -106,6 +106,7 @@ async function search({query, sourcesId, advancedQuery}) {
             indices.push(index.index_id);
         }
     }
+    logger.debug(`Searching in indices: ${indices.join(",")}`);
     if (indices.length === 0) {
         logger.error("No indices found for the given sources");
         return {hits: {hits: []}};
@@ -116,6 +117,7 @@ async function search({query, sourcesId, advancedQuery}) {
         body: queryBuilder,
         scroll: "10s",
     });
+    logger.debug(`Search results: ${response.hits.total.value}`);
     return response;
 }
 
-- 
GitLab


From cadfdfdb34d08f9c195e79843462019c5a88c087 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Fri, 31 Jan 2025 09:16:18 +0100
Subject: [PATCH 07/15] [search] changed MAXIMUM_HITS_SIZE to a env variable

---
 __tests__/api/search/post.test.js | 2 --
 app/dal/elasticService.js         | 7 +++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/__tests__/api/search/post.test.js b/__tests__/api/search/post.test.js
index d844c8b..e28811e 100644
--- a/__tests__/api/search/post.test.js
+++ b/__tests__/api/search/post.test.js
@@ -36,7 +36,6 @@ describe("getQueryResultsHandler", () => {
       sourcesId: [1, 2, 3],
       fieldsId: [1, 2, 3],
       index: "test_index",
-      scroll_id: "test_scroll_id",
     };
     const mockResponse = { hits: { hits: [] } };
     search.mockResolvedValue(mockResponse);
@@ -54,7 +53,6 @@ describe("getQueryResultsHandler", () => {
       sourcesId: [1, 2, 3],
       fieldsId: [1, 2, 3],
       index: "test_index",
-      scroll_id: "test_scroll_id",
     };
     search.mockImplementation(() => {
       throw error;
diff --git a/app/dal/elasticService.js b/app/dal/elasticService.js
index 0db7319..3dac2fa 100644
--- a/app/dal/elasticService.js
+++ b/app/dal/elasticService.js
@@ -59,14 +59,14 @@ async function bulk(body) {
 async function search({query, sourcesId, advancedQuery}) {
     const client = await getClientInstance();
     // Configure maximum number of results (hits) returned by query
-    const MAXIMUM_HITS_SIZE = 10000;
     let queryBuilder;
     if (!advancedQuery) {
         queryBuilder = {
-            size: MAXIMUM_HITS_SIZE,
+            size: process.env.MAXIMUM_HITS_SIZE || 10000,
             query: {
-                simple_query_string: {
+                query_string: {
                     query: query,
+                    default_operator: "OR",
                     analyze_wildcard: true,
                     lenient: true,
                     minimum_should_match: "1"
@@ -115,7 +115,6 @@ async function search({query, sourcesId, advancedQuery}) {
     const response = await client.search({
         index: indices.join(","),
         body: queryBuilder,
-        scroll: "10s",
     });
     logger.debug(`Search results: ${response.hits.total.value}`);
     return response;
-- 
GitLab


From a7ec88d5ae61d4b6e134e4ec60b6087e7fbaacd6 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Fri, 31 Jan 2025 14:42:06 +0100
Subject: [PATCH 08/15] [search] added forgotten env variable to advanced
 search query builder

---
 app/dal/elasticService.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/dal/elasticService.js b/app/dal/elasticService.js
index 3dac2fa..c408220 100644
--- a/app/dal/elasticService.js
+++ b/app/dal/elasticService.js
@@ -80,7 +80,7 @@ async function search({query, sourcesId, advancedQuery}) {
             logger.debug("Advanced query: " + query);
             query = JSON.parse(query);
             queryBuilder = {
-                size: MAXIMUM_HITS_SIZE,
+                size: process.env.MAXIMUM_HITS_SIZE || 10000,
                 query: query
             };
         } catch (error) {
-- 
GitLab


From 5e6dc16cac775fa424568afe93975d1d8c26c7f4 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Wed, 5 Feb 2025 15:09:37 +0100
Subject: [PATCH 09/15] v1.2.0

---
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package.json b/package.json
index bf0ccb5..d68ed68 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "in-sylva.gatekeeper",
-  "version": "1.1.1-alpha",
+  "version": "1.2.0",
   "description": "",
   "main": "index.js",
   "scripts": {
-- 
GitLab


From dfed29c1d3d819bcac762bb6b789c8d6348d0a74 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Fri, 7 Feb 2025 15:58:52 +0100
Subject: [PATCH 10/15] [StdFields] added a getter for default display fields

---
 app/api/index.js           |  2 ++
 app/api/std_fields/get.js  | 11 +++++++++++
 app/dal/stdFieldService.js | 10 ++++++++++
 3 files changed, 23 insertions(+)

diff --git a/app/api/index.js b/app/api/index.js
index 52944e5..494e0bb 100644
--- a/app/api/index.js
+++ b/app/api/index.js
@@ -58,6 +58,7 @@ const { deletePolicyHandler } = require("@/app/api/policies/delete");
 
 const {
   getStdFieldsHandler,
+  getDefaultDisplayStdFieldsHandler,
   getPublicStdFieldsHandler,
   getStdFieldHandler,
 } = require("@/app/api/std_fields/get");
@@ -161,6 +162,7 @@ routers.delete(
 
 // std_fields
 routers.get("/std_fields", getStdFieldsHandler);
+routers.get("/std_fields/default", getDefaultDisplayStdFieldsHandler);
 routers.get("/public_std_fields", getPublicStdFieldsHandler);
 routers.get("/std_fields/:id", getStdFieldHandler);
 routers.post("/std_fields", createOrUpdateStdFieldHandler);
diff --git a/app/api/std_fields/get.js b/app/api/std_fields/get.js
index 35b649b..41c8485 100644
--- a/app/api/std_fields/get.js
+++ b/app/api/std_fields/get.js
@@ -8,6 +8,7 @@ const {
   getStdFields,
   getStdField,
   getPublicStdFields,
+  getDefaultDisplayStdFields
 } = require("@/app/dal/stdFieldService");
 
 async function getStdFieldsHandler(ctx) {
@@ -19,6 +20,15 @@ async function getStdFieldsHandler(ctx) {
   }
 }
 
+async function getDefaultDisplayStdFieldsHandler(ctx) {
+  try {
+    ctx.body = await getDefaultDisplayStdFields();
+    ctx.status = 200;
+  } catch (err) {
+    handleInternalError(err, ctx);
+  }
+}
+
 async function getPublicStdFieldsHandler(ctx) {
   try {
     ctx.body = await getPublicStdFields();
@@ -44,6 +54,7 @@ async function getStdFieldHandler(ctx) {
 
 module.exports = {
   getStdFieldsHandler,
+  getDefaultDisplayStdFieldsHandler,
   getPublicStdFieldsHandler,
   getStdFieldHandler,
 };
diff --git a/app/dal/stdFieldService.js b/app/dal/stdFieldService.js
index 90a7cb9..8b1cd8b 100644
--- a/app/dal/stdFieldService.js
+++ b/app/dal/stdFieldService.js
@@ -22,6 +22,15 @@ async function getStdFields() {
     return stdFields;
 }
 
+async function getDefaultDisplayStdFields() {
+    const stdFields = await prisma.stdField.findMany({
+        where: {
+            default_display_fields: true,
+        },
+    });
+    return stdFields;
+}
+
 async function getPublicStdFields() {
     const stdFields = await prisma.stdField.findMany({
         where: {
@@ -158,6 +167,7 @@ async function deleteAllStdFields() {
 module.exports = {
     getStdField,
     getStdFields,
+    getDefaultDisplayStdFields,
     getPublicStdFields,
     createOrUpdateStdField,
     deleteAllStdFields,
-- 
GitLab


From 907e76f4f4001290ef3dd603596cea35ee4daa6e Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Fri, 7 Feb 2025 15:59:24 +0100
Subject: [PATCH 11/15] v1.2.1

---
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package.json b/package.json
index d68ed68..87aca96 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "in-sylva.gatekeeper",
-  "version": "1.2.0",
+  "version": "1.2.1",
   "description": "",
   "main": "index.js",
   "scripts": {
-- 
GitLab


From 6e70fc64af904b90d92a6d21ede5b0ad2e5b71bc Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Fri, 21 Feb 2025 11:43:44 +0100
Subject: [PATCH 12/15] [Prisma] Added createdAt to Source model

---
 .../20250220144308_source_createdat_date/migration.sql          | 2 ++
 prisma/schema.prisma                                            | 1 +
 2 files changed, 3 insertions(+)
 create mode 100644 prisma/migrations/20250220144308_source_createdat_date/migration.sql

diff --git a/prisma/migrations/20250220144308_source_createdat_date/migration.sql b/prisma/migrations/20250220144308_source_createdat_date/migration.sql
new file mode 100644
index 0000000..8fcdf89
--- /dev/null
+++ b/prisma/migrations/20250220144308_source_createdat_date/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "sources" ADD COLUMN     "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 1f9fc9a..b8f6cda 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -71,6 +71,7 @@ model Source {
   source_indices SourceIndices[]
   providers      SourceUser[]
   policies       PolicySource[]
+  createdAt      DateTime        @default(now())
 
   @@map("sources")
 }
-- 
GitLab


From fe77f5a16d578536afea58105c36db0a893e89aa Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Fri, 21 Feb 2025 11:45:33 +0100
Subject: [PATCH 13/15] v1.2.2

---
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package.json b/package.json
index 87aca96..a01f31c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "in-sylva.gatekeeper",
-  "version": "1.2.1",
+  "version": "1.2.2",
   "description": "",
   "main": "index.js",
   "scripts": {
-- 
GitLab


From b141785a40a44b57c9f44ca481c22e501d7f081c Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Mon, 3 Mar 2025 14:10:57 +0100
Subject: [PATCH 14/15] [Prisma] Added createdAt to source

---
 .../20250303094658_created_at_to_history/migration.sql       | 2 ++
 prisma/schema.prisma                                         | 5 +++--
 2 files changed, 5 insertions(+), 2 deletions(-)
 create mode 100644 prisma/migrations/20250303094658_created_at_to_history/migration.sql

diff --git a/prisma/migrations/20250303094658_created_at_to_history/migration.sql b/prisma/migrations/20250303094658_created_at_to_history/migration.sql
new file mode 100644
index 0000000..0291f0f
--- /dev/null
+++ b/prisma/migrations/20250303094658_created_at_to_history/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "search_history" ADD COLUMN     "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index b8f6cda..d0a3299 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -24,13 +24,14 @@ model User {
 }
 
 model SearchHistory {
-  id           Int    @id @default(autoincrement())
+  id           Int      @id @default(autoincrement())
   user_id      Int
-  user         User   @relation(fields: [user_id], references: [id], onDelete: Cascade)
+  user         User     @relation(fields: [user_id], references: [id], onDelete: Cascade)
   query        String
   name         String
   ui_structure String
   description  String
+  createdAt    DateTime @default(now())
 
   @@map("search_history")
 }
-- 
GitLab


From 557b30a52069addb9ffa1bfc93dcc552e127ac41 Mon Sep 17 00:00:00 2001
From: rbisson <remi.bisson@inrae.fr>
Date: Mon, 3 Mar 2025 14:11:05 +0100
Subject: [PATCH 15/15] v1.2.3

---
 package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package.json b/package.json
index a01f31c..4963b7a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "in-sylva.gatekeeper",
-  "version": "1.2.2",
+  "version": "1.2.3",
   "description": "",
   "main": "index.js",
   "scripts": {
-- 
GitLab