Browse Source

query node - active video counters generalization II

ondratra 3 years ago
parent
commit
d3b5700002

+ 1 - 2
query-node/mappings/src/content/nft.ts

@@ -1,7 +1,7 @@
 // TODO: solve events' relations to videos and other entites that can be changed or deleted
 
 import { DatabaseManager, EventContext, StoreContext, SubstrateEvent } from '@joystream/hydra-common'
-import { genericEventFields, inconsistentState, logger } from '../common'
+import { genericEventFields, inconsistentState, logger, EntityType } from '../common'
 import {
   // entities
   Auction,
@@ -44,7 +44,6 @@ import * as joystreamTypes from '@joystream/types/augment/all/types'
 import { Content } from '../../generated/types'
 import { FindConditions } from 'typeorm'
 import BN from 'bn.js'
-import { EntityType } from '../common'
 
 async function getExistingEntity<Type extends Video | Membership>(
   store: DatabaseManager,

+ 4 - 0
query-node/mappings/src/derivedPropertiesManager/applications/activeVideoCounters.ts

@@ -112,10 +112,12 @@ class StorageDataObjectChangeListener_ThumbnailPhoto implements IListener<Storag
     oldValue: StorageDataObject | undefined,
     newValue: StorageDataObject
   ): IChangePair<IAvcChange> | undefined
+
   hasValueChanged(
     oldValue: StorageDataObject,
     newValue: StorageDataObject | undefined
   ): IChangePair<IAvcChange> | undefined
+
   hasValueChanged(oldValue: StorageDataObject, newValue: StorageDataObject): IChangePair<IAvcChange> | undefined {
     const oldVideo = oldValue?.videoThumbnail
     const newVideo = newValue?.videoThumbnail
@@ -143,10 +145,12 @@ class StorageDataObjectChangeListener_Media implements IListener<StorageDataObje
     oldValue: StorageDataObject | undefined,
     newValue: StorageDataObject
   ): IChangePair<IAvcChange> | undefined
+
   hasValueChanged(
     oldValue: StorageDataObject,
     newValue: StorageDataObject | undefined
   ): IChangePair<IAvcChange> | undefined
+
   hasValueChanged(oldValue: StorageDataObject, newValue: StorageDataObject): IChangePair<IAvcChange> | undefined {
     const oldVideo = oldValue?.videoMedia
     const newVideo = newValue?.videoMedia

+ 0 - 1
query-node/mappings/src/forum.ts

@@ -69,7 +69,6 @@ import { MAX_TAGS_PER_FORUM_THREAD } from '@joystream/metadata-protobuf/consts'
 import { Not, In } from 'typeorm'
 import { Bytes } from '@polkadot/types'
 import _ from 'lodash'
-import BN from 'bn.js'
 
 async function getCategory(store: DatabaseManager, categoryId: string, relations?: string[]): Promise<ForumCategory> {
   const category = await store.get(ForumCategory, { where: { id: categoryId }, relations })

+ 2 - 4
query-node/mappings/src/storage/index.ts

@@ -18,7 +18,6 @@ import {
   StorageDataObject,
   StorageSystemParameters,
   GeoCoordinates,
-  Video,
 } from 'query-node/dist/model'
 import BN from 'bn.js'
 import { getById, inconsistentState, INT32MAX, toNumber } from '../common'
@@ -43,7 +42,6 @@ import {
   distributionOperatorId,
   distributionBucketIdByFamilyAndIndex,
 } from './utils'
-import { In } from 'typeorm'
 import { getAllManagers } from '../derivedPropertiesManager/applications'
 
 // STORAGE BUCKETS
@@ -251,10 +249,10 @@ export async function storage_PendingDataObjectsAccepted({ event, store }: Event
   ): void {
     const ids = entities.map((entity) => entity.id.toString())
 
-    for (let entity of entities) {
+    for (const entity of entities) {
       updateEntity(entity)
 
-      for (let relation of relations) {
+      for (const relation of relations) {
         const target = relation.reduce((acc, relationPart) => {
           if (!acc) {
             return acc