Skip to content

Commit

Permalink
Usman/tidbits collection (#79)
Browse files Browse the repository at this point in the history
* Removed Aspect Ratio from Tidbit Collections

* Removed VideoAspectRatio from TidbitsCollection

* Removed VideoAspectRatio from TidbitsCollection

* Removed VideoAspectRatio from TidbitsCollection

* Delete ByteCollectionCategory functionality added

* Deleted file : deleteByteCollectionCategory.ts

* Added file : deleteByteCollectionCategory.ts

* deleteByteCollectionCategory.ts updated

* Removed VideoAspectRatio from ProjectByteCollection | Corrected deletion of Category by adding Archive

* Corrected Prettier Issue

* Fix prettier issue

---------

Co-authored-by: robin <[email protected]>
  • Loading branch information
UsmanSaleem2003 and RobinNagpal authored Jul 3, 2024
1 parent 04cc2d4 commit fc27ead
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the column `video_aspect_ratio` on the `project_byte_collections` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "byte_collections_category" ADD COLUMN "archive" BOOLEAN DEFAULT false;

-- AlterTable
ALTER TABLE "project_byte_collections" DROP COLUMN "video_aspect_ratio";
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ model ByteCollectionCategory {
Space Space @relation(fields: [spaceId], references: [id])
status String @default("Active") @db.VarChar(255)
priority Int @default(50)
archive Boolean? @default(false)
@@map("byte_collections_category")
}
Expand Down Expand Up @@ -641,7 +642,6 @@ model ProjectByteCollection {
seoMeta Json? @map("seo_meta") @db.JsonB
priority Int @default(50) @map("priority")
videoUrl String? @map("video_url") @db.VarChar(1024)
videoAspectRatio String? @map("video_aspect_ratio") @db.VarChar(255)
@@map("project_byte_collections")
}
Expand Down
16 changes: 13 additions & 3 deletions src/graphql/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export type ByteCollectionByte = {

export type ByteCollectionCategory = {
__typename?: 'ByteCollectionCategory';
archive: Scalars['Boolean'];
byteCollectionIds: Array<Scalars['String']>;
excerpt?: Maybe<Scalars['String']>;
id: Scalars['String'];
Expand Down Expand Up @@ -316,6 +317,7 @@ export type ByteUserInput = {

export type CategoryWithByteCollection = {
__typename?: 'CategoryWithByteCollection';
archive: Scalars['Boolean'];
byteCollections: Array<ByteCollection>;
creator: Scalars['String'];
excerpt: Scalars['String'];
Expand Down Expand Up @@ -1252,6 +1254,7 @@ export type Mutation = {
deleteAndPullCourseRepo: GitCourse;
deleteByte: Scalars['Boolean'];
deleteByteCollection: Scalars['Boolean'];
deleteByteCollectionCategory: ByteCollectionCategory;
deleteChatbotCategory: Scalars['Boolean'];
deleteChatbotFAQ: Scalars['Boolean'];
deleteChatbotUserQuestion: Scalars['Boolean'];
Expand Down Expand Up @@ -1474,6 +1477,12 @@ export type MutationDeleteByteCollectionArgs = {
};


export type MutationDeleteByteCollectionCategoryArgs = {
categoryId: Scalars['String'];
spaceId: Scalars['String'];
};


export type MutationDeleteChatbotCategoryArgs = {
id: Scalars['String'];
spaceId: Scalars['String'];
Expand Down Expand Up @@ -2156,7 +2165,6 @@ export type ProjectByteCollection = {
priority: Scalars['Int'];
seoMeta?: Maybe<SeoMeta>;
status: Scalars['String'];
videoAspectRatio?: Maybe<Scalars['String']>;
videoUrl?: Maybe<Scalars['String']>;
};

Expand Down Expand Up @@ -3069,6 +3077,7 @@ export type UpsertAcademyTaskInput = {
};

export type UpsertByteCollectionCategory = {
archive: Scalars['Boolean'];
byteCollectionIds: Array<Scalars['String']>;
excerpt: Scalars['String'];
id: Scalars['String'];
Expand Down Expand Up @@ -3187,7 +3196,6 @@ export type UpsertProjectByteCollectionInput = {
projectId: Scalars['String'];
seoMeta?: InputMaybe<SeoMetaInput>;
status: Scalars['String'];
videoAspectRatio?: InputMaybe<Scalars['String']>;
videoUrl?: InputMaybe<Scalars['String']>;
};

Expand Down Expand Up @@ -4009,6 +4017,7 @@ export type ByteCollectionByteResolvers<ContextType = any, ParentType extends Re
};

export type ByteCollectionCategoryResolvers<ContextType = any, ParentType extends ResolversParentTypes['ByteCollectionCategory'] = ResolversParentTypes['ByteCollectionCategory']> = {
archive?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
byteCollectionIds?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>;
excerpt?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
Expand Down Expand Up @@ -4121,6 +4130,7 @@ export type ByteUserInputResolvers<ContextType = any, ParentType extends Resolve
};

export type CategoryWithByteCollectionResolvers<ContextType = any, ParentType extends ResolversParentTypes['CategoryWithByteCollection'] = ResolversParentTypes['CategoryWithByteCollection']> = {
archive?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
byteCollections?: Resolver<Array<ResolversTypes['ByteCollection']>, ParentType, ContextType>;
creator?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
excerpt?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
Expand Down Expand Up @@ -4750,6 +4760,7 @@ export type MutationResolvers<ContextType = any, ParentType extends ResolversPar
deleteAndPullCourseRepo?: Resolver<ResolversTypes['GitCourse'], ParentType, ContextType, RequireFields<MutationDeleteAndPullCourseRepoArgs, 'courseKey' | 'spaceId'>>;
deleteByte?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationDeleteByteArgs, 'byteId' | 'spaceId'>>;
deleteByteCollection?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationDeleteByteCollectionArgs, 'byteCollectionId'>>;
deleteByteCollectionCategory?: Resolver<ResolversTypes['ByteCollectionCategory'], ParentType, ContextType, RequireFields<MutationDeleteByteCollectionCategoryArgs, 'categoryId' | 'spaceId'>>;
deleteChatbotCategory?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationDeleteChatbotCategoryArgs, 'id' | 'spaceId'>>;
deleteChatbotFAQ?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationDeleteChatbotFaqArgs, 'id' | 'spaceId'>>;
deleteChatbotUserQuestion?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationDeleteChatbotUserQuestionArgs, 'id' | 'spaceId'>>;
Expand Down Expand Up @@ -4956,7 +4967,6 @@ export type ProjectByteCollectionResolvers<ContextType = any, ParentType extends
priority?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
seoMeta?: Resolver<Maybe<ResolversTypes['SEOMeta']>, ParentType, ContextType>;
status?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
videoAspectRatio?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
videoUrl?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { QueryByteCollectionCategoryWithByteCollectionsArgs } from '@/graphql/generated/graphql';
import { getSpaceById } from '@/graphql/operations/space';
import { checkEditSpacePermission } from '@/helpers/space/checkEditSpacePermission';
import { prisma } from '@/prisma';
import { IncomingMessage } from 'http';

export default async function deleteByteCollection(_: any, args: QueryByteCollectionCategoryWithByteCollectionsArgs, context: IncomingMessage) {
const spaceById = await getSpaceById(args.spaceId);

checkEditSpacePermission(spaceById, context);

try {
const updatedbyteCollectionCategory = await prisma.byteCollectionCategory.update({
where: {
id: args.categoryId,
},
data: {
archive: true,
},
});

return updatedbyteCollectionCategory;
} catch (e) {
console.log(e);
throw e;
}
}
2 changes: 0 additions & 2 deletions src/graphql/mutations/project/upsertProjectByteCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default async function upsertProjectByteCollection(_: any, args: Mutation
updatedAt: new Date(),
priority: args.input.priority,
videoUrl: args.input.videoUrl,
videoAspectRatio: args.input.videoAspectRatio,
seoMeta: {
title: args.input.seoMeta?.title ?? args.input.name,
description: args.input.seoMeta?.description ?? args.input.description,
Expand All @@ -40,7 +39,6 @@ export default async function upsertProjectByteCollection(_: any, args: Mutation
status: args.input.status,
priority: args.input.priority,
videoUrl: args.input.videoUrl,
videoAspectRatio: args.input.videoAspectRatio,
archived: false,
seoMeta: {
title: args.input.seoMeta?.title ?? args.input.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function getByteCollectionCategoryWithByteCollections(spaceId: stri
creator: byteCollectionCategory.creator,
status: byteCollectionCategory.status,
priority: byteCollectionCategory.priority,
archive: !!byteCollectionCategory.archive!,
};
}

Expand Down
4 changes: 4 additions & 0 deletions src/graphql/schemas/byteCollectionCategory.gql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extend type Query {

extend type Mutation {
upsertByteCollectionCategory(spaceId: String!, input: UpsertByteCollectionCategory!): ByteCollectionCategory!
deleteByteCollectionCategory(spaceId: String!, categoryId: String!): ByteCollectionCategory!
}

type CategoryWithByteCollection {
Expand All @@ -16,6 +17,7 @@ type CategoryWithByteCollection {
status: String!
priority: Int!
byteCollections: [ByteCollection!]!
archive: Boolean!
}

type ByteCollectionCategory {
Expand All @@ -26,6 +28,7 @@ type ByteCollectionCategory {
status: String!
priority: Int!
byteCollectionIds: [String!]!
archive: Boolean!
}

input UpsertByteCollectionCategory {
Expand All @@ -37,6 +40,7 @@ input UpsertByteCollectionCategory {
status: String!
priority: Int!
byteCollectionIds: [String!]!
archive: Boolean!
}

enum ByteCollectionCategoryStatus {
Expand Down
2 changes: 0 additions & 2 deletions src/graphql/schemas/project/projectByteCollection.gql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type ProjectByteCollection {
seoMeta: SEOMeta
priority: Int!
videoUrl: String
videoAspectRatio: String
}

input UpsertProjectByteCollectionInput {
Expand All @@ -33,5 +32,4 @@ input UpsertProjectByteCollectionInput {
seoMeta: SEOMetaInput
priority: Int!
videoUrl: String
videoAspectRatio: String
}
2 changes: 2 additions & 0 deletions src/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import createByteCollection from '@/graphql/mutations/byteCollection/createByteC
import deleteByteCollection from '@/graphql/mutations/byteCollection/deleteByteCollection';
import updateByteCollection from '@/graphql/mutations/byteCollection/updateByteCollection';
import upsertByteCollectionCategory from './graphql/mutations/byteCollectionCategory/upsertByteCollectionCategory';
import deleteByteCollectionCategory from '@/graphql/mutations/byteCollectionCategory/deleteByteCollectionCategory';
import deleteChatbotCategory from '@/graphql/mutations/chatbot/deleteChatbotCategory';
import deleteChatbotFAQ from '@/graphql/mutations/chatbot/deleteChatbotFAQ';
import deleteChatbotUserQuestion from '@/graphql/mutations/chatbot/deleteChatbotUserQuestion';
Expand Down Expand Up @@ -102,6 +103,7 @@ export default {

upsertByte,
upsertByteCollectionCategory,
deleteByteCollectionCategory,
submitByte,
deleteByte,
upsertByteRating,
Expand Down

0 comments on commit fc27ead

Please sign in to comment.