ソースを参照

Add actual values for other fields

Anuj Bansal 3 年 前
コミット
c6e362aa7c

+ 10 - 1
query-node/mappings/bootstrap-data/scripts/fetchCategories.ts

@@ -6,6 +6,9 @@ import fetch from 'cross-fetch'
 type categoryType = {
   id: string
   name: string
+  createdInBlock: number
+  createdAt: Date
+  updatedAt: Date
 }
 
 async function main() {
@@ -41,14 +44,20 @@ async function getCategories(queryNodeProvider, categoryType): Promise<Array<cat
       ${categoryType} {
         id
         name
+        createdInBlock
+        createdAt
+        updatedAt
       }
     }
   `
   const queryResult = await queryNodeProvider.query({ query: GET_ALL_CATEGORY_ITEMS })
-  const categories = queryResult.data[categoryType].map(({ id, name }) => {
+  const categories = queryResult.data[categoryType].map(({ id, name, createdInBlock, createdAt, updatedAt }) => {
     return {
       id,
       name,
+      createdInBlock,
+      createdAt,
+      updatedAt,
     }
   })
   return categories

+ 6 - 0
query-node/mappings/bootstrap-data/types.ts

@@ -37,9 +37,15 @@ export type WorkingGroupsJson = {
 export type VideoCategoryJson = {
   id: string
   name: string
+  createdInBlock: number
+  createdAt: Date
+  updatedAt: Date
 }
 
 export type ChannelCategoryJson = {
   id: string
   name: string
+  createdInBlock: number
+  createdAt: Date
+  updatedAt: Date
 }

+ 6 - 6
query-node/mappings/bootstrap.ts

@@ -76,9 +76,9 @@ export async function bootstrapData({ store }: StoreContext): Promise<void> {
         id: m.id,
         name: m.name,
         channels: [],
-        createdInBlock: 1,
-        createdAt: new Date(),
-        updatedAt: new Date(),
+        createdInBlock: m.createdInBlock,
+        createdAt: new Date(m.createdAt),
+        updatedAt: new Date(m.updatedAt),
       })
   )
   await Promise.all(channelCategories.map((m) => store.save<ChannelCategory>(m)))
@@ -89,9 +89,9 @@ export async function bootstrapData({ store }: StoreContext): Promise<void> {
         id: m.id,
         name: m.name,
         videos: [],
-        createdInBlock: 1,
-        createdAt: new Date(),
-        updatedAt: new Date(),
+        createdInBlock: m.createdInBlock,
+        createdAt: new Date(m.createdAt),
+        updatedAt: new Date(m.updatedAt),
       })
   )
   await Promise.all(videoCategories.map((m) => store.save<VideoCategory>(m)))