feat: add the view graph on tiktok
This commit is contained in:
@@ -21,6 +21,8 @@ export async function GET() {
|
||||
followers: 124,
|
||||
likes: 856,
|
||||
videoCount: 1,
|
||||
views: 3432,
|
||||
profileViews: 287,
|
||||
displayName: "CrowMate studio",
|
||||
avatarUrl: "",
|
||||
plan: (user as any)?.plan ?? "free",
|
||||
@@ -56,8 +58,7 @@ export async function GET() {
|
||||
|
||||
try {
|
||||
const stats = await fetchUserStats(accessToken, openId);
|
||||
|
||||
// Upsert TrackedAccount + snapshot automatique
|
||||
|
||||
try {
|
||||
let account = await prisma.trackedAccount.findFirst({
|
||||
where: { userId, platform: "tiktok" },
|
||||
@@ -78,14 +79,12 @@ export async function GET() {
|
||||
followers: stats.followers ?? 0,
|
||||
likes: stats.likes ?? 0,
|
||||
videoCount: stats.videoCount ?? 0,
|
||||
views: 0,
|
||||
views: stats.views ?? 0,
|
||||
},
|
||||
});
|
||||
} catch (snapshotErr) {
|
||||
console.error("[TikTok snapshot save error]", snapshotErr);
|
||||
}
|
||||
|
||||
// Inclure le plan dans la réponse
|
||||
const user = await prisma.user.findUnique({ where: { id: userId } });
|
||||
return NextResponse.json({ ...stats, plan: (user as any)?.plan ?? "free" });
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user