Skip to content

Commit 9ad24bb

Browse files
committed
revalidate cache
1 parent a47fc01 commit 9ad24bb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/github/services/user.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GITHUB_APP_PRIVATE_KEY, GITHUB_APP_WEBHOOK_SECRET } from "@/lib/constants";
22
import { db } from "@/lib/db";
33
import { getRepositoryDefaultBranch, getRepositoryReadme } from "@/lib/github/services/repo";
4+
import { repositoryCache } from "@/lib/repository/cache";
45
import { App } from "octokit";
56

67
export const sendInstallationDetails = async (
@@ -94,6 +95,7 @@ export const sendInstallationDetails = async (
9495
role: "member",
9596
},
9697
});
98+
repositoryCache.revalidate({ userId: newUser.id, id: installationPrisma.id });
9799
console.log(`Membership upserted for user: ${newUser.login}`);
98100
})
99101
);
@@ -128,6 +130,7 @@ export const sendInstallationDetails = async (
128130
},
129131
});
130132
console.log(`Membership upserted for user: ${newUser.login}`);
133+
repositoryCache.revalidate({ userId: newUser.id, id: installationPrisma.id });
131134
}
132135

133136
if (repos) {

lib/repository/service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ export const fetchRepoDetails = (id: string) =>
149149
export const getRepositoriesForUser = (userId: string) =>
150150
unstable_cache(
151151
async (): Promise<TRepository[]> => {
152+
console.log(`getRepositoriesForUser called with userId: ${userId}`);
153+
console.log(`Starting database transaction`);
152154
try {
153155
const userRepositories = await db.repository.findMany({
154156
where: {
@@ -161,7 +163,7 @@ export const getRepositoriesForUser = (userId: string) =>
161163
},
162164
},
163165
});
164-
166+
console.log(`Database transaction completed successfully`);
165167
return userRepositories as TRepository[];
166168
} catch (error) {
167169
console.error(`Failed to get repositories for user: ${error}`);

0 commit comments

Comments
 (0)