Skip to content

Commit

Permalink
refactor: remove used feild + add DB ER diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesh-gupta committed May 26, 2024
1 parent f564f90 commit c28ba77
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 8 deletions.
19 changes: 16 additions & 3 deletions convex/project.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v } from "convex/values";
import { mutation, query } from "@/convex/_generated//server";
import { v } from "convex/values";
import { ProjectStatus } from "./types";

export const create = mutation({
Expand All @@ -23,7 +23,6 @@ export const create = mutation({
creatorName: identity.name!,
description: args.description,
status: args.status,
team: [identity.subject],
});

return projectId;
Expand Down Expand Up @@ -59,7 +58,21 @@ export const remove = mutation({
.withIndex("by_project", (q) => q.eq("projectId", args.id))
.collect();

await Promise.all(workItems.map((wi) => ctx.db.delete(wi._id)));
workItems.map((wi) => ctx.db.delete(wi._id));

const files = await ctx.db
.query("files")
.withIndex("by_project", (q) => q.eq("projectId", args.id))
.collect();

files.map((file) => ctx.db.delete(file._id));

const links = await ctx.db
.query("links")
.withIndex("by_project", (q) => q.eq("projectId", args.id))
.collect();

links.map((link) => ctx.db.delete(link._id));

await ctx.db.delete(args.id);
},
Expand Down
5 changes: 2 additions & 3 deletions convex/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ export default defineSchema({
title: v.string(),
description: v.optional(v.string()),
status: ProjectStatus,
team: v.array(v.string()),
creatorId: v.string(),
creatorName: v.string(),
orgId: v.string(),
}).index("by_org", ["orgId"]),

workItems: defineTable({
title: v.string(),
description: v.optional(v.string()),
assigneeId: v.id("users"),
assignee: v.string(),
label: TaskType,
priority: TaskPriority,
projectId: v.id("projects"),
status: TaskStatus,
title: v.string(),
description: v.optional(v.string()),
}).index("by_project", ["projectId"]),

users: defineTable({
Expand Down
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Projectify Docs

## DB Schema ER Diagram

![DB Schema ER Diagram](https://raw.githubusercontent.com/vignesh-gupta/projectify/master/docs/assets/er-diagram.svg)
4 changes: 4 additions & 0 deletions docs/assets/er-diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions docs/code-export-5-25-2024-7_52_31-PM.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

title Project Management System

projects [icon: briefcase, color: lightblue]{
id string pk
title string
description string
status string
creatorId string
creatorName string
orgId string
}

workItems [icon: check-square, color: yellow]{
id string pk
title string
description string
assigneeId string fk
assignee string
label string
priority string
projectId string fk
status string
}

users [icon: user, color: green]{
id string pk
email string
firstName string
imageUrl string
clerkId string
}

teams [icon: users, color: blue]{
id string pk
name string
clerkId string
imageUrl string
createdBy string fk
}

team_memberships [icon: user-check, color: purple]{
id string pk
teamId string fk
userId string fk
isAdmin boolean
}

links [icon: link, color: orange]{
id string pk
title string
url string
icon string
projectId string fk
}

files [icon: file, color: red]{
id string pk
title string
storageId string
projectId string fk
type string
}

messages [icon: message-circle, color: pink]{
id string pk
content string
projectId string fk
senderId string fk
senderName string
senderImageUrl string
}
// End of tables
// define relationships
projects.orgId > orgs.id
workItems.projectId > projects.id
workItems.assigneeId > users.id
teams.createdBy > users.id
team_memberships.teamId > teams.id
team_memberships.userId > users.id
links.projectId > projects.id
files.projectId > projects.id
messages.projectId > projects.id
messages.senderId > users.id
6 changes: 4 additions & 2 deletions lib/hooks/use-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { useEffect, useRef } from "react";

export const useScroll = (
behavior?: ScrollBehavior | undefined,
block?: ScrollLogicalPosition | undefined
block?: ScrollLogicalPosition | undefined,
dependencies: any[] = []
) => {
const scrollRef = useRef<null | HTMLDivElement>(null);

Expand All @@ -13,7 +14,8 @@ export const useScroll = (
block,
behavior,
});
}, [behavior, block]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [behavior, block, ...dependencies]);

return scrollRef;
};

0 comments on commit c28ba77

Please sign in to comment.