feature(dashboard,api): add timezone support
* feat(dashboard): add support for today, yesterday etc (timezones) * fix(db): escape js dates * fix(dashboard): ensure we support default timezone * final fixes * remove complete series and add sql with fill instead
This commit is contained in:
committed by
GitHub
parent
46bfeee131
commit
680727355b
@@ -14,10 +14,6 @@ export type IServiceMember = Prisma.MemberGetPayload<{
|
||||
}> & { access: ProjectAccess[] };
|
||||
export type IServiceProjectAccess = ProjectAccess;
|
||||
|
||||
export function transformOrganization<T>(org: T) {
|
||||
return org;
|
||||
}
|
||||
|
||||
export async function getOrganizations(userId: string | null) {
|
||||
if (!userId) return [];
|
||||
|
||||
@@ -34,10 +30,10 @@ export async function getOrganizations(userId: string | null) {
|
||||
},
|
||||
});
|
||||
|
||||
return organizations.map(transformOrganization);
|
||||
return organizations;
|
||||
}
|
||||
|
||||
export function getOrganizationBySlug(slug: string) {
|
||||
export function getOrganizationById(slug: string) {
|
||||
return db.organization.findUniqueOrThrow({
|
||||
where: {
|
||||
id: slug,
|
||||
@@ -59,7 +55,7 @@ export async function getOrganizationByProjectId(projectId: string) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return transformOrganization(project.organization);
|
||||
return project.organization;
|
||||
}
|
||||
|
||||
export const getOrganizationByProjectIdCached = cacheable(
|
||||
@@ -258,3 +254,32 @@ export async function getOrganizationSubscriptionChartEndDate(
|
||||
|
||||
return endDate;
|
||||
}
|
||||
|
||||
const DEFAULT_TIMEZONE = 'UTC';
|
||||
|
||||
export async function getSettingsForOrganization(organizationId: string) {
|
||||
const organization = await db.organization.findUniqueOrThrow({
|
||||
where: {
|
||||
id: organizationId,
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
timezone: organization.timezone || DEFAULT_TIMEZONE,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getSettingsForProject(projectId: string) {
|
||||
const project = await db.project.findUniqueOrThrow({
|
||||
where: {
|
||||
id: projectId,
|
||||
},
|
||||
include: {
|
||||
organization: true,
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
timezone: project.organization.timezone || DEFAULT_TIMEZONE,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user