Ver código fonte

format rowcount

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 1 ano atrás
pai
commit
a799a6d0f3

+ 1 - 1
client/src/pages/collections/Collections.tsx

@@ -404,7 +404,7 @@ const Collections = () => {
         </span>
         </span>
       ),
       ),
       formatter(v) {
       formatter(v) {
-        return formatNumber(Number(v.rowCount));
+        return formatNumber(v.rowCount);
       },
       },
     },
     },
     {
     {

+ 2 - 1
client/src/pages/databases/tree/index.tsx

@@ -6,6 +6,7 @@ import { makeStyles, Theme, Tooltip } from '@material-ui/core';
 import { useNavigate, Params } from 'react-router-dom';
 import { useNavigate, Params } from 'react-router-dom';
 import { CollectionObject } from '@server/types';
 import { CollectionObject } from '@server/types';
 import clcx from 'clsx';
 import clcx from 'clsx';
+import { formatNumber } from '@/utils';
 
 
 export type TreeNodeType = 'db' | 'collection' | 'partition' | 'segment';
 export type TreeNodeType = 'db' | 'collection' | 'partition' | 'segment';
 
 
@@ -155,7 +156,7 @@ const CollectionNode: React.FC<{ data: CollectionObject }> = ({ data }) => {
     <div className={classes.collectionNode}>
     <div className={classes.collectionNode}>
       <div>
       <div>
         {data.collection_name}
         {data.collection_name}
-        <span className={classes.count}>({data.rowCount})</span>
+        <span className={classes.count}>({formatNumber(data.rowCount || 0)})</span>
       </div>
       </div>
       <div className={classes.right}>
       <div className={classes.right}>
         <Tooltip title={loadStatus}>
         <Tooltip title={loadStatus}>

+ 8 - 4
client/src/pages/search/VectorSearch.tsx

@@ -22,6 +22,7 @@ import {
   getVectorFieldOptions,
   getVectorFieldOptions,
   cloneObj,
   cloneObj,
   generateVector,
   generateVector,
+  formatNumber,
 } from '@/utils';
 } from '@/utils';
 import { LOADING_STATE, DYNAMIC_FIELD, DataTypeEnum } from '@/consts';
 import { LOADING_STATE, DYNAMIC_FIELD, DataTypeEnum } from '@/consts';
 import { getLabelDisplayedRows } from './Utils';
 import { getLabelDisplayedRows } from './Utils';
@@ -217,11 +218,14 @@ const VectorSearch = () => {
   // fetch data
   // fetch data
   const loadedCollections = collections.filter(
   const loadedCollections = collections.filter(
     c => c.status === LOADING_STATE.LOADED
     c => c.status === LOADING_STATE.LOADED
-  );
+  ) as CollectionFullObject[];
+  // sort by rowCounts
+  loadedCollections.sort((a, b) => b.rowCount - a.rowCount);
+
   const collectionOptions: Option[] = useMemo(
   const collectionOptions: Option[] = useMemo(
     () =>
     () =>
       loadedCollections.map(c => ({
       loadedCollections.map(c => ({
-        label: c.collection_name,
+        label: `${c.collection_name}(${formatNumber(c.rowCount)})`,
         value: c.collection_name,
         value: c.collection_name,
       })),
       })),
     [loadedCollections]
     [loadedCollections]
@@ -414,7 +418,7 @@ const VectorSearch = () => {
             </Typography>
             </Typography>
           )}
           )}
           {selectedFieldDimension !== 0 ? (
           {selectedFieldDimension !== 0 ? (
-            <Button
+            <CustomButton
               className={classes.exampleBtn}
               className={classes.exampleBtn}
               onClick={() => {
               onClick={() => {
                 const dim =
                 const dim =
@@ -425,7 +429,7 @@ const VectorSearch = () => {
               }}
               }}
             >
             >
               {btnTrans('example')}
               {btnTrans('example')}
-            </Button>
+            </CustomButton>
           ) : null}
           ) : null}
           <CustomButton
           <CustomButton
             variant="contained"
             variant="contained"

+ 1 - 1
server/src/types/collections.type.ts

@@ -44,7 +44,7 @@ export interface DescribeIndexRes extends DescribeIndexResponse {
 export type CollectionFullObject = {
 export type CollectionFullObject = {
   collection_name: string;
   collection_name: string;
   schema: SchemaObject;
   schema: SchemaObject;
-  rowCount: number | string;
+  rowCount: number;
   createdTime: number;
   createdTime: number;
   aliases: string[];
   aliases: string[];
   description: string;
   description: string;