Skip to content

Commit 7084211

Browse files
authored
Merge pull request #36 from diggerhq/feat/drifted-projects-filter
Only show drifted projects on the Drift page
2 parents fadebae + 5cb8ba3 commit 7084211

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/app/(dynamic-pages)/(authenticated-pages)/(application-pages)/org/[organizationId]/(specific-organization-pages)/drift/DriftedProjectsWithPagination.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function UserDriftedProjectsWithPagination({
1515
getLoggedInUserOrganizationRole(organizationId)
1616
]);
1717
const [projects, totalPages] = await Promise.all([
18-
getProjectsListForUser({ ...filters, organizationId, userRole, userId }),
18+
getProjectsListForUser({ ...filters, organizationId, userRole, userId, driftedOnly: true }),
1919
getProjectsCountForUser({ ...filters, organizationId, userId }),
2020
]);
2121

src/app/(dynamic-pages)/(authenticated-pages)/(application-pages)/org/[organizationId]/(specific-organization-pages)/drift/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default async function DriftsPage({
2525
return (
2626
<div className="flex flex-col space-y-4 max-w-5xl mt-8">
2727
<PageHeading
28-
title="Drifted projects (alpha)"
28+
title="Drifted projects"
2929
/>
3030
<div className="md:w-1/3">
3131
<Search placeholder="Search projects" />

src/data/user/projects.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,20 @@ export async function getProjectsListForUser({
303303
organizationId,
304304
query = '',
305305
teamIds = [],
306+
driftedOnly = false,
306307
}: {
307308
userId: string;
308309
userRole: Enum<'organization_member_role'>;
309310
organizationId: string;
310311
query?: string;
311312
teamIds?: number[];
313+
driftedOnly?: boolean;
312314
}): Promise<ProjectListType[]> {
313315
const supabase = createSupabaseUserServerComponentClient();
314316

315317
let supabaseQuery = supabase
316318
.from('projects')
317-
.select('id,name, slug, latest_action_on, created_at, repo_id')
319+
.select('id, name, slug, latest_action_on, created_at, repo_id, latest_drift_output')
318320
.eq('organization_id', organizationId)
319321
.ilike('name', `%${query}%`);
320322

@@ -347,9 +349,13 @@ export async function getProjectsListForUser({
347349

348350
if (!data) return [];
349351

352+
const driftFilteredProjects = driftedOnly
353+
? data.filter(project => !!project.latest_drift_output)
354+
: data;
355+
350356
// Fetch repo details for each project
351357
const projectsWithRepoDetails = await Promise.all(
352-
data.map(async (project) => {
358+
driftFilteredProjects.map(async (project) => {
353359
const repoDetails = await getRepoDetails(project.repo_id);
354360
const { repo_id, ...projectWithoutRepoId } = project;
355361
return {

0 commit comments

Comments
 (0)