ソースを参照

drop @joystream/types/media + @joystream/types/content-directory

Joystream Stats 2 年 前
コミット
a6974a9ae4
2 ファイル変更0 行追加109 行削除
  1. 0 37
      api.ts
  2. 0 72
      media.ts

+ 0 - 37
api.ts

@@ -26,8 +26,6 @@ import {
   SealedVote,
   Seats,
 } from "@joystream/types/council";
-import { Entity, EntityId } from "@joystream/types/content-directory";
-import { ContentId, DataObject } from "@joystream/types/media";
 import {
   MemberId,
   Membership,
@@ -548,38 +546,3 @@ export const getPaidMembershipTermsById = (
   id: PaidTermId | number
 ): Promise<PaidMembershipTerms> =>
   api.query.members.paidMembershipTermsById.at(hash, id);
-
-// media
-export const getNextEntity = async (
-  api: ApiPromise,
-  hash: Hash
-): Promise<number> =>
-  (
-    (await api.query.contentDirectory.nextEntityId.at(hash)) as EntityId
-  ).toNumber();
-
-export const getNextChannel = (api: ApiPromise, hash: Hash): Promise<number> =>
-  api.query.content.nextChannelId.at(hash);
-
-export const getNextVideo = (api: ApiPromise, hash: Hash): Promise<number> =>
-  api.query.content.nextVideoId.at(hash);
-
-export const getEntity = (
-  api: ApiPromise,
-  hash: Hash,
-  id: number
-): Promise<Entity> => api.query.contentDirectory.entityById.at(hash, id);
-
-export const getDataObjects = async (
-  api: ApiPromise
-): Promise<Map<ContentId, DataObject>> =>
-  (await api.query.dataDirectory.dataByContentId.entries()) as unknown as Map<
-    ContentId,
-    DataObject
-  >;
-
-export const getDataObject = async (
-  api: ApiPromise,
-  id: ContentId
-): Promise<Option<DataObject>> =>
-  (await api.query.dataDirectory.dataByContentId(id)) as Option<DataObject>;

+ 0 - 72
media.ts

@@ -1,72 +0,0 @@
-import { ApiPromise } from "@polkadot/api";
-import { Vec, Option } from "@polkadot/types";
-import { Hash } from "@joystream/types/common";
-import { Entity } from "@joystream/types/content-directory";
-import { ContentId, DataObject } from "@joystream/types/media";
-import { getNextEntity, getEntity, getDataObject } from "./api";
-import { Channel, Media } from "./types";
-
-const CHANNEL_CLASS_iD = 1;
-const VIDEO_CLASS_iD = 10;
-
-const getEntities = async (
-  api: ApiPromise,
-  hash: Hash
-): Promise<Map<number, Entity>> => {
-  let nrEntities: number = await getNextEntity(api, hash);
-  let entities = new Map<number, Entity>();
-  for (let i = 0; i < nrEntities; ++i) {
-    const entity: Entity = await getEntity(api, hash, i);
-    entities.set(i, entity);
-  }
-  return entities;
-};
-
-export const computeUsedSpaceInMbs = async (
-  api: ApiPromise,
-  contentIds: Vec<ContentId>
-): Promise<number> => {
-  let space = 0;
-  for (let contentId of contentIds) {
-    const dataObject: Option<DataObject> = await getDataObject(api, contentId);
-    space += dataObject.unwrap().size_in_bytes.toNumber();
-  }
-  return space / 1024 / 1024;
-};
-
-export const parseVideos = async (
-  entities: Map<number, Entity>
-): Promise<Media[]> => {
-  let videos: Media[] = [];
-  for (let [key, entity] of entities) {
-    if (entity.class_id.toNumber() != VIDEO_CLASS_iD || entity.values.isEmpty)
-      continue;
-    let values = Array.from(entity.getField("values").entries());
-    if (values.length < 2 || values[2].length < 1) continue;
-
-    let title = values[2][1].getValue().toString();
-    videos.push(new Media(key, title));
-  }
-
-  return videos;
-};
-
-const parseChannels = async (
-  entities: Map<number, Entity>
-): Promise<Channel[]> => {
-  let channels: Channel[] = [];
-
-  for (let [key, entity] of entities) {
-    if (
-      entity.class_id.toNumber() != CHANNEL_CLASS_iD ||
-      entity.values.isEmpty
-    ) {
-      continue;
-    }
-    let values = Array.from(entity.getField("values").entries());
-
-    let title = values[0][1].getValue().toString();
-    channels.push(new Channel(key, title));
-  }
-  return channels;
-};