From 4401f080a976c6c974f459b05e24b6370735ffdc Mon Sep 17 00:00:00 2001 From: Shlomi Date: Mon, 18 Nov 2024 12:43:04 +0200 Subject: [PATCH] fix: choose random lines for data sample display --- .gitignore | 2 ++ package-lock.json | 16 +++++++++++----- package.json | 2 ++ src/app/components/Header/Header.tsx | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c6bba59..5f2add9 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ + +/localData # Logs logs *.log diff --git a/package-lock.json b/package-lock.json index 14698dd..4a30be9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "elp-query-ui", + "name": "dbbot-ui", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "elp-query-ui", + "name": "dbbot-ui", "version": "0.1.0", "dependencies": { "@emotion/cache": "^11.11.0", @@ -19,6 +19,7 @@ "fs": "^0.0.1-security", "fs-extra": "^11.2.0", "json2csv": "^6.0.0-alpha.2", + "lodash": "^4.17.21", "next": "^14.2.12", "react": "^18", "react-dom": "^18", @@ -33,6 +34,7 @@ "@types/fs-extra": "^11.0.4", "@types/jest": "^29.5.13", "@types/json2csv": "^5.0.7", + "@types/lodash": "^4.17.13", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", @@ -2483,6 +2485,12 @@ "@types/node": "*" } }, + "node_modules/@types/lodash": { + "version": "4.17.13", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.13.tgz", + "integrity": "sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg==", + "dev": true + }, "node_modules/@types/node": { "version": "20.10.5", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", @@ -6394,9 +6402,7 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true, - "license": "MIT" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, "node_modules/lodash.get": { "version": "4.4.2", diff --git a/package.json b/package.json index e6eb581..97e6670 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "fs": "^0.0.1-security", "fs-extra": "^11.2.0", "json2csv": "^6.0.0-alpha.2", + "lodash": "^4.17.21", "next": "^14.2.12", "react": "^18", "react-dom": "^18", @@ -36,6 +37,7 @@ "@types/fs-extra": "^11.0.4", "@types/jest": "^29.5.13", "@types/json2csv": "^5.0.7", + "@types/lodash": "^4.17.13", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", diff --git a/src/app/components/Header/Header.tsx b/src/app/components/Header/Header.tsx index 613897a..493dde2 100644 --- a/src/app/components/Header/Header.tsx +++ b/src/app/components/Header/Header.tsx @@ -18,6 +18,7 @@ import { NO_HELP_DESCRIPTION, } from "@/app/general/constants"; import { getTableInfo } from "@/app/general/utils"; +import _ from "lodash"; export default function Header({ bot }: HeaderProps) { const [openAttribute, setOpenAttribute] = useState(false); @@ -26,7 +27,7 @@ export default function Header({ bot }: HeaderProps) { const helpDescription = bot?._details.helpDescription; const { botHeaders, botColumns, rows } = getTableInfo(bot); - const sampleRows = rows.slice(0, SAMPLE_SIZE); + const sampleRows = _.sampleSize(rows, SAMPLE_SIZE); const attributesRows = botColumns?.map((column) => ({ name: column.displayName,