Browse Source

content-directory: replace counters in channel with vec

Mokhtar Naamani 4 years ago
parent
commit
e0a27bee7a
2 changed files with 22 additions and 12 deletions
  1. 19 9
      runtime-modules/content/src/lib.rs
  2. 3 3
      types/src/content/index.ts

+ 19 - 9
runtime-modules/content/src/lib.rs

@@ -169,23 +169,30 @@ pub struct ChannelCategoryUpdateParameters {
 /// If a channel is deleted, all videos, playlists and series will also be deleted.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct ChannelRecord<MemberId, CuratorGroupId, ChannelCategoryId, DAOId, Balance> {
+pub struct ChannelRecord<
+    MemberId,
+    CuratorGroupId,
+    ChannelCategoryId,
+    DAOId,
+    Balance,
+    VideoId,
+    PlaylistId,
+    SeriesId,
+> {
     /// The owner of a channel
     owner: ChannelOwner<MemberId, CuratorGroupId, DAOId>,
     /// The category the channel belongs to
     in_category: ChannelCategoryId,
-    /// The number of videos under this channel
-    number_of_videos: u32,
-    /// The number of playlists under this channel
-    number_of_playlists: u32,
-    /// The number of series under this channel
-    number_of_series: u32,
+    /// The videos under this channel
+    videos: Vec<VideoId>,
+    /// The playlists under this channel
+    playlists: Vec<PlaylistId>,
+    /// The series under this channel
+    series: Vec<SeriesId>,
     /// If curators have censored this channel or not
     is_censored: bool,
     /// Earned revenue yet to be withdrawn by channel owner
     revenue: Balance,
-    // TODO: I think we need to add these instead of the counters!
-    // videos: Vec<VideoId>, playlists: Vec<PlaylistId>, series: Vec<SeriesId>
 }
 
 // Channel alias type for simplification.
@@ -195,6 +202,9 @@ pub type Channel<T> = ChannelRecord<
     <T as Trait>::ChannelCategoryId,
     <T as StorageOwnership>::DAOId,
     BalanceOf<T>,
+    <T as Trait>::VideoId,
+    <T as Trait>::PlaylistId,
+    <T as Trait>::SeriesId,
 >;
 
 /// A request to buy a channel by a new ChannelOwner.

+ 3 - 3
types/src/content/index.ts

@@ -36,9 +36,9 @@ export class ChannelOwner extends JoyEnum({
 export class Channel extends JoyStructDecorated({
   owner: ChannelOwner,
   in_category: ChannelCategoryId,
-  number_of_videos: u32,
-  number_of_playlists: u32,
-  number_of_series: u32,
+  videos: Vec.with(VideoId),
+  playlists: Vec.with(PlaylistId),
+  series: Vec.with(SeriesId),
   is_censored: bool,
   revenue: u128,
 }) {}