Browse Source

Merge pull request #180 from nameczz/main

add created time in collection
Tumao 4 years ago
parent
commit
067fe73fec

+ 8 - 0
client/src/http/Collection.ts

@@ -6,6 +6,7 @@ import { IndexState, ShowCollectionsType } from '../types/Milvus';
 import { formatNumber } from '../utils/Common';
 import { formatNumber } from '../utils/Common';
 import BaseModel from './BaseModel';
 import BaseModel from './BaseModel';
 import { FieldHttp } from './Field';
 import { FieldHttp } from './Field';
+import dayjs from 'dayjs';
 
 
 export class CollectionHttp extends BaseModel implements CollectionView {
 export class CollectionHttp extends BaseModel implements CollectionView {
   private autoID!: string;
   private autoID!: string;
@@ -15,6 +16,7 @@ export class CollectionHttp extends BaseModel implements CollectionView {
   private index_status!: string;
   private index_status!: string;
   private id!: string;
   private id!: string;
   private isLoaded!: boolean;
   private isLoaded!: boolean;
+  private createdTime!: string;
   private schema!: {
   private schema!: {
     fields: Field[];
     fields: Field[];
   };
   };
@@ -126,4 +128,10 @@ export class CollectionHttp extends BaseModel implements CollectionView {
         return ChildrenStatusType.FINISH;
         return ChildrenStatusType.FINISH;
     }
     }
   }
   }
+
+  get _createdTime(): string {
+    return this.createdTime
+      ? dayjs(Number(this.createdTime)).format('YYYY-MM-DD HH:mm:ss')
+      : '';
+  }
 }
 }

+ 1 - 0
client/src/i18n/cn/collection.ts

@@ -16,6 +16,7 @@ const collectionTrans = {
   name: 'Name',
   name: 'Name',
   status: 'Status',
   status: 'Status',
   desc: 'Description',
   desc: 'Description',
+  createdTime: 'Created Time',
 
 
   // create dialog
   // create dialog
   createTitle: 'Create Collection',
   createTitle: 'Create Collection',

+ 1 - 0
client/src/i18n/en/collection.ts

@@ -16,6 +16,7 @@ const collectionTrans = {
   name: 'Name',
   name: 'Name',
   status: 'Status',
   status: 'Status',
   desc: 'Description',
   desc: 'Description',
+  createdTime: 'Created Time',
 
 
   // create dialog
   // create dialog
   createTitle: 'Create Collection',
   createTitle: 'Create Collection',

+ 6 - 0
client/src/pages/collections/Collections.tsx

@@ -362,6 +362,12 @@ const Collections = () => {
       disablePadding: false,
       disablePadding: false,
       label: collectionTrans('desc'),
       label: collectionTrans('desc'),
     },
     },
+    {
+      id: '_createdTime',
+      align: 'left',
+      disablePadding: false,
+      label: collectionTrans('createdTime'),
+    },
     {
     {
       id: 'indexCreatingElement',
       id: 'indexCreatingElement',
       align: 'left',
       align: 'left',

+ 2 - 5
server/generate-csv.ts

@@ -3,10 +3,7 @@ import { createObjectCsvWriter as createCsvWriter } from 'csv-writer';
 // use to test vector insert
 // use to test vector insert
 const csvWriter = createCsvWriter({
 const csvWriter = createCsvWriter({
   path: './vectors.csv',
   path: './vectors.csv',
-  header: [
-    { id: 'vector', title: 'vector' },
-    { id: 'age', title: 'age' },
-  ],
+  header: [{ id: 'vector', title: 'vector' }],
 });
 });
 
 
 const records = [];
 const records = [];
@@ -22,7 +19,7 @@ const generateVector = (dimension) => {
 };
 };
 
 
 while (records.length < 50000) {
 while (records.length < 50000) {
-  const value = generateVector(128);
+  const value = generateVector(4);
   records.push({ vector: value, age: 10 });
   records.push({ vector: value, age: 10 });
 }
 }
 
 

+ 2 - 2
server/package.json

@@ -32,7 +32,7 @@
     "@nestjs/websockets": "^8.0.4",
     "@nestjs/websockets": "^8.0.4",
     "@types/passport-jwt": "^3.0.5",
     "@types/passport-jwt": "^3.0.5",
     "@types/passport-local": "^1.0.33",
     "@types/passport-local": "^1.0.33",
-    "@zilliz/milvus2-sdk-node": "^1.0.4",
+    "@zilliz/milvus2-sdk-node": "^1.0.6",
     "body-parser": "^1.19.0",
     "body-parser": "^1.19.0",
     "cache-manager": "^3.4.4",
     "cache-manager": "^3.4.4",
     "class-transformer": "^0.4.0",
     "class-transformer": "^0.4.0",
@@ -87,4 +87,4 @@
     "coverageDirectory": "../coverage",
     "coverageDirectory": "../coverage",
     "testEnvironment": "node"
     "testEnvironment": "node"
   }
   }
-}
+}

+ 5 - 1
server/src/collections/collections.service.ts

@@ -110,11 +110,15 @@ export class CollectionsService {
         const collectionStatistics = await this.getCollectionStatistics({
         const collectionStatistics = await this.getCollectionStatistics({
           collection_name: name,
           collection_name: name,
         });
         });
+        const autoID = collectionInfo.schema.fields.find(
+          (v) => v.is_primary_key === true,
+        )?.autoID;
+
         data.push({
         data.push({
           collection_name: name,
           collection_name: name,
           schema: collectionInfo.schema,
           schema: collectionInfo.schema,
           description: collectionInfo.schema.description,
           description: collectionInfo.schema.description,
-          autoID: collectionInfo.schema.autoID,
+          autoID,
           rowCount: findKeyValue(collectionStatistics.stats, ROW_COUNT),
           rowCount: findKeyValue(collectionStatistics.stats, ROW_COUNT),
           id: collectionInfo.collectionID,
           id: collectionInfo.collectionID,
           isLoaded: loadedCollections.collection_names.includes(name),
           isLoaded: loadedCollections.collection_names.includes(name),

+ 4 - 4
server/yarn.lock

@@ -1319,10 +1319,10 @@
   resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
   resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"
   integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
   integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
 
 
-"@zilliz/milvus2-sdk-node@^1.0.4":
-  version "1.0.4"
-  resolved "https://registry.yarnpkg.com/@zilliz/milvus2-sdk-node/-/milvus2-sdk-node-1.0.4.tgz#3e32edb5338abbcb710ea7da8b4e2ba2603fcea5"
-  integrity sha512-67KTHnZP1pLAGDct15XPZfUIHJy/4RPGcUQ3rAMepEj/4BmxCAL8rpRqThFL+UPJz4QYcphoqL5HQDNK59IH0A==
+"@zilliz/milvus2-sdk-node@^1.0.6":
+  version "1.0.6"
+  resolved "https://registry.yarnpkg.com/@zilliz/milvus2-sdk-node/-/milvus2-sdk-node-1.0.6.tgz#e4293395f7cb24a437a9df92d2059c3b7e8f1889"
+  integrity sha512-n1nIafhd7FOPF5js6FoeJ9OuNX0ujIUMkINQPZyBCg8vVILQoOqyaTLcBCcVnqa+ejg1b2KXHlcTYrxWTJfTtw==
   dependencies:
   dependencies:
     "@grpc/grpc-js" "^1.2.12"
     "@grpc/grpc-js" "^1.2.12"
     "@grpc/proto-loader" "^0.6.0"
     "@grpc/proto-loader" "^0.6.0"