mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-18 13:34:06 +01:00
refactor: rename all database field to snake_case
This commit is contained in:
parent
d8a2f13d6c
commit
0d14e15d13
@ -81,7 +81,7 @@ const CheckoutPage = ({
|
||||
} else {
|
||||
try {
|
||||
const supabase = createSupabaseClient();
|
||||
const { data, error } = await supabase.from("InvestmentDeal").insert([
|
||||
const { data, error } = await supabase.from("investment_deal").insert([
|
||||
{
|
||||
investorId: investor_id,
|
||||
projectId: project_id,
|
||||
|
||||
@ -25,15 +25,15 @@ const TopProjects = async () => {
|
||||
{topProjectsData.map((project) => (
|
||||
<Link href={`/deals/${project.id}`} key={project.id}>
|
||||
<ProjectCard
|
||||
name={project.projectName}
|
||||
description={project.projectShortDescription}
|
||||
imageUri={project.cardImage}
|
||||
joinDate={new Date(project.publishedTime).toLocaleDateString()}
|
||||
location={project.Business.location}
|
||||
tags={project.ItemTag.map((item) => item.Tag.value)}
|
||||
minInvestment={project.ProjectInvestmentDetail[0]?.minInvestment || 0}
|
||||
name={project.project_name}
|
||||
description={project.project_short_description}
|
||||
imageUri={project.card_image_url}
|
||||
joinDate={new Date(project.published_time).toLocaleDateString()}
|
||||
location={project.business.location}
|
||||
tags={project.item_tag.map((item) => item.tag.value)}
|
||||
minInvestment={project.project_investment_detail[0]?.min_investment || 0}
|
||||
totalInvestor={0}
|
||||
totalRaised={project.ProjectInvestmentDetail[0]?.totalInvestment || 0}
|
||||
totalRaised={project.project_investment_detail[0]?.total_investment || 0}
|
||||
/>
|
||||
</Link>
|
||||
))}
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
import { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
|
||||
function getAllTagsQuery(client: SupabaseClient) {
|
||||
return client.from("Tag").select("id, value");
|
||||
return client.from("tag").select("id, value");
|
||||
}
|
||||
|
||||
function getALlFundedStatusQuery(client: SupabaseClient) {
|
||||
return client.from("FundedStatus").select("id, value, description");
|
||||
return client.from("funded_status").select("id, value, description");
|
||||
}
|
||||
|
||||
function getAllBusinessTypeQuery(client: SupabaseClient) {
|
||||
return client.from("BusinessType").select("id, value, description");
|
||||
return client.from("business_type").select("id, value, description");
|
||||
}
|
||||
|
||||
export { getAllTagsQuery, getALlFundedStatusQuery, getAllBusinessTypeQuery };
|
||||
export { getAllBusinessTypeQuery, getALlFundedStatusQuery, getAllTagsQuery };
|
||||
|
||||
@ -6,33 +6,33 @@ async function getTopProjects(
|
||||
) {
|
||||
try {
|
||||
const { data, error } = await client
|
||||
.from("Project")
|
||||
.from("project")
|
||||
.select(
|
||||
`
|
||||
id,
|
||||
projectName,
|
||||
businessId,
|
||||
publishedTime,
|
||||
projectShortDescription,
|
||||
cardImage,
|
||||
ProjectInvestmentDetail (
|
||||
minInvestment,
|
||||
totalInvestment,
|
||||
targetInvestment,
|
||||
investmentDeadline
|
||||
project_name,
|
||||
business_id,
|
||||
published_time,
|
||||
project_short_description,
|
||||
card_image_url,
|
||||
project_investment_detail (
|
||||
min_investment,
|
||||
total_investment,
|
||||
target_investment,
|
||||
investment_deadline
|
||||
),
|
||||
ItemTag (
|
||||
Tag (
|
||||
item_tag (
|
||||
tag (
|
||||
id,
|
||||
value
|
||||
)
|
||||
),
|
||||
Business (
|
||||
business (
|
||||
location
|
||||
)
|
||||
`,
|
||||
)
|
||||
.order("publishedTime", { ascending: false })
|
||||
.order("published_time", { ascending: false })
|
||||
.limit(numberOfRecords);
|
||||
|
||||
if (error) {
|
||||
@ -48,20 +48,20 @@ async function getTopProjects(
|
||||
}
|
||||
|
||||
function getProjectDataQuery(client: SupabaseClient, projectId: number) {
|
||||
return client.from("Project").select(
|
||||
return client.from("project").select(
|
||||
`
|
||||
project_name:projectName,
|
||||
project_short_description:projectShortDescription,
|
||||
project_description:projectDescription,
|
||||
published_time:publishedTime,
|
||||
...ProjectInvestmentDetail!inner (
|
||||
min_investment:minInvestment,
|
||||
total_investment:totalInvestment,
|
||||
target_investment:targetInvestment,
|
||||
investment_deadline:investmentDeadline
|
||||
project_name,
|
||||
project_short_description,
|
||||
project_description,
|
||||
published_time,
|
||||
...project_investment_detail!inner (
|
||||
min_investment,
|
||||
total_investment,
|
||||
target_investment,
|
||||
investment_deadline
|
||||
),
|
||||
tags:ItemTag!inner (
|
||||
...Tag!inner (
|
||||
tags:item_tag!inner (
|
||||
...tag!inner (
|
||||
tag_name:value
|
||||
)
|
||||
)
|
||||
@ -70,20 +70,20 @@ function getProjectDataQuery(client: SupabaseClient, projectId: number) {
|
||||
}
|
||||
|
||||
async function getProjectData(client: SupabaseClient, projectId: number) {
|
||||
const query = client.from("Project").select(
|
||||
const query = client.from("project").select(
|
||||
`
|
||||
project_name:projectName,
|
||||
project_short_description:projectShortDescription,
|
||||
project_description:projectDescription,
|
||||
published_time:publishedTime,
|
||||
...ProjectInvestmentDetail!inner (
|
||||
min_investment:minInvestment,
|
||||
total_investment:totalInvestment,
|
||||
target_investment:targetInvestment,
|
||||
investment_deadline:investmentDeadline
|
||||
project_name,
|
||||
project_short_description,
|
||||
project_description,
|
||||
published_time,
|
||||
...project_investment_detail!inner (
|
||||
min_investment,
|
||||
total_investment,
|
||||
target_investment,
|
||||
investment_deadline
|
||||
),
|
||||
tags:ItemTag!inner (
|
||||
...Tag!inner (
|
||||
tags:item_tag!inner (
|
||||
...tag!inner (
|
||||
tag_name:value
|
||||
)
|
||||
)
|
||||
@ -123,35 +123,35 @@ function searchProjectsQuery(
|
||||
const start = (page - 1) * pageSize;
|
||||
const end = start + pageSize - 1;
|
||||
|
||||
let query = client.from("Project").select(
|
||||
let query = client.from("project").select(
|
||||
`
|
||||
project_id:id,
|
||||
project_name:projectName,
|
||||
published_time:publishedTime,
|
||||
project_short_description:projectShortDescription,
|
||||
card_image_url:cardImage,
|
||||
...ProjectStatus!Project_projectStatusId_fkey!inner (
|
||||
project_name,
|
||||
published_time,
|
||||
project_short_description,
|
||||
card_image_url,
|
||||
...project_status!project_project_status_id_fkey!inner (
|
||||
project_status:value
|
||||
),
|
||||
...ProjectInvestmentDetail!inner (
|
||||
min_investment:minInvestment,
|
||||
total_investment:totalInvestment,
|
||||
target_investment:targetInvestment,
|
||||
investment_deadline:investmentDeadline
|
||||
...project_investment_detail!inner (
|
||||
min_investment,
|
||||
total_investment,
|
||||
target_investment,
|
||||
investment_deadline
|
||||
),
|
||||
tags:ItemTag!inner (
|
||||
...Tag!inner (
|
||||
tags:item_tag!inner (
|
||||
...tag!inner (
|
||||
tag_name:value
|
||||
)
|
||||
),
|
||||
...Business!inner (
|
||||
...businessType!inner (
|
||||
...business!inner (
|
||||
...business_type!inner (
|
||||
business_type:value
|
||||
),
|
||||
business_location:location
|
||||
)
|
||||
`,
|
||||
).order("publishedTime", { ascending: false }).range(start, end);
|
||||
).order("published_time", { ascending: false }).range(start, end);
|
||||
|
||||
if (sortByTimeFilter === "all") {
|
||||
sortByTimeFilter = undefined;
|
||||
@ -170,19 +170,19 @@ function searchProjectsQuery(
|
||||
}
|
||||
|
||||
if (searchTerm) {
|
||||
query = query.ilike("projectName", `%${searchTerm}%`);
|
||||
query = query.ilike("project_name", `%${searchTerm}%`);
|
||||
}
|
||||
|
||||
if (tagsFilter) {
|
||||
query = query.in("ItemTag.Tag.value", tagsFilter);
|
||||
query = query.in("item_tag.tag.value", tagsFilter);
|
||||
}
|
||||
|
||||
if (projectStatus) {
|
||||
query = query.eq("ProjectStatus.value", projectStatus);
|
||||
query = query.eq("project_status.value", projectStatus);
|
||||
}
|
||||
|
||||
if (businessTypeFilter) {
|
||||
query = query.eq("Business.businessType.value", businessTypeFilter);
|
||||
query = query.eq("business.business_type.value", businessTypeFilter);
|
||||
}
|
||||
|
||||
return query;
|
||||
|
||||
@ -1,35 +1,44 @@
|
||||
import { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
function getBusinesses(client: SupabaseClient, query: string | null) {
|
||||
return client.from("Business").select("id, businessName, joinedDate").ilike("businessName", `%${query}%`);
|
||||
return client.from("business").select("id, business_name, joined_date").ilike(
|
||||
"business_name",
|
||||
`%${query}%`,
|
||||
);
|
||||
}
|
||||
|
||||
function getProjects(client: SupabaseClient, businessIds: string[]) {
|
||||
return client
|
||||
.from("Project")
|
||||
.from("project")
|
||||
.select(
|
||||
`
|
||||
id,
|
||||
projectName,
|
||||
businessId,
|
||||
publishedTime,
|
||||
projectShortDescription,
|
||||
ProjectInvestmentDetail (
|
||||
minInvestment,
|
||||
totalInvestment,
|
||||
targetInvestment
|
||||
project_name,
|
||||
business_id,
|
||||
published_time,
|
||||
project_short_description,
|
||||
project_investment_detail (
|
||||
min_investment,
|
||||
total_investment,
|
||||
target_investment
|
||||
)
|
||||
`
|
||||
`,
|
||||
)
|
||||
.in("businessId", businessIds);
|
||||
.in("business_id", businessIds);
|
||||
}
|
||||
|
||||
function getTags(client: SupabaseClient, projectIds: string[]) {
|
||||
return client.from("ItemTag").select("itemId, Tag (value)").in("itemId", projectIds);
|
||||
return client.from("item_tag").select("item_id, tag (value)").in(
|
||||
"item_id",
|
||||
projectIds,
|
||||
);
|
||||
}
|
||||
|
||||
function getInvestmentCounts(client: SupabaseClient, projectIds: string[]) {
|
||||
return client.from("InvestmentDeal").select("*", { count: "exact", head: true }).in("projectId", projectIds);
|
||||
return client.from("investment_deal").select("*", {
|
||||
count: "exact",
|
||||
head: true,
|
||||
}).in("project_id", projectIds);
|
||||
}
|
||||
|
||||
export { getBusinesses, getProjects, getTags, getInvestmentCounts };
|
||||
export { getBusinesses, getInvestmentCounts, getProjects, getTags };
|
||||
|
||||
@ -3,7 +3,7 @@ import { SupabaseClient } from "@supabase/supabase-js";
|
||||
async function getUserProfile(client: SupabaseClient, userId: string) {
|
||||
try {
|
||||
const { data, error } = await client
|
||||
.from("Profiles")
|
||||
.from("profiles")
|
||||
.select("updated_at, username, full_name, avatar_url, website, bio")
|
||||
.eq("id", userId)
|
||||
.single();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user