-
Notifications
You must be signed in to change notification settings - Fork 14
feat: algolia video troubleshooter frontend #8464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: tannerfleming/vmt-189-backend-video-managment-algolia-troubleshooting
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis PR introduces Algolia integration capabilities for video indexing. It adds GraphQL schemas and resolvers to check video and variant presence in Algolia indices, update indices, and report mismatches. The changes include helper functions for Algolia queries, resolver implementations, and a troubleshooting UI for video publishers. Changes
Sequence DiagramsequenceDiagram
actor Publisher
participant UI as Admin UI
participant API as GraphQL API
participant Resolver as Video Resolver
participant Algolia as Algolia Client
participant DB as Prisma DB
Publisher->>UI: Click "Check Video in Algolia"
UI->>API: checkVideoInAlgolia(videoId)
API->>Resolver: resolve checkVideoInAlgolia
Resolver->>DB: fetch minimal video data
DB-->>Resolver: video record
Resolver->>Algolia: getObject(videoId)
Algolia-->>Resolver: record or error
Resolver->>Resolver: compute mismatches
Resolver-->>API: result {ok, mismatches, recordUrl}
API-->>UI: result
UI->>UI: display mismatches or success
UI-->>Publisher: show status with links
Publisher->>UI: Click "Check Variants in Algolia"
UI->>API: checkVideoVariantsInAlgolia(videoId)
API->>Resolver: resolve checkVideoVariantsInAlgolia
Resolver->>DB: fetch all variant IDs
DB-->>Resolver: variant IDs
loop For each variant
Resolver->>Algolia: getObject(variantId)
Algolia-->>Resolver: found or not found
end
Resolver-->>API: result {ok, missingVariants, browseUrl}
API-->>UI: result
UI->>UI: display missing variants
UI-->>Publisher: show summary and browse link
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…roubleshooting' into tannerfleming/vmt-190-frontend-video-managment-algolia-troubleshooting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apis/api-media/src/schema/videoVariant/videoVariant.ts (1)
579-601: Avoid doubleupdateParentCollectionLanguagesinvocation and keep error handling consistentInside the
wasPublished !== isNowPublishedbranch you already callupdateParentCollectionLanguages(currentVariant.videoId)within atry/catch, and then call it again unconditionally after that block. This:
- Invokes the cascade twice on status-change paths.
- Reintroduces a throwing code path for
updateParentCollectionLanguages(the outer call has notry/catch), whereas earlier errors were only logged.If the goal is to always keep parent collections in sync (even when published status doesn’t change), consider keeping a single call, e.g.:
- Remove the inner call, and
- Wrap the unconditional call in its own
try/catchwith logging so resolver behavior stays non‑throwing.
🧹 Nitpick comments (4)
apps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx (1)
472-533: Consider usingokto distinguish “all variants indexed” from “check failed”The variants panel currently derives status solely from:
(algoliaVariantsData.checkVideoVariantsInAlgolia.missingVariants ?? []).lengthso a
null/undefinedmissingVariantsproduces “All variants found ✓”. If the backend ever signals failure viaok: falsewithmissingVariantsomitted, this UI would incorrectly report success.You might instead:
- Prefer
okas the primary flag (e.g., show an “unable to determine status” message whenok === falseandmissingVariantsis null), or- At least guard the “All variants found ✓” message behind
ok === true.apis/api-media/src/schema/video/video.ts (3)
788-799: Silent error handling may hide important failures.The catch block swallows all errors without logging. If
getObjectfails for reasons other than "record not found" (e.g., network issues, authentication problems), the error will be silently ignored and treated as a missing record.Consider adding error logging or distinguishing between "not found" and other error types:
- } catch { + } catch (error) { + // Log non-404 errors for debugging + console.error(`Failed to fetch Algolia record for video ${videoId}:`, error) return { ok: false, mismatches: [],
825-841: Sequential API calls may cause performance issues.The loop makes sequential Algolia API calls for each variant. For videos with many variants, this could be slow. Consider batching the checks using Algolia's
getObjectsmethod.Additionally, the condition on line 832-833 treats a null
videoIdas a valid match. Verify this is the intended behavior.- for (const variant of variants) { - try { - const record = await client.getObject({ - indexName: videoVariantsIndex, - objectID: variant.id - }) - const objectIdMatches = record.objectID === variant.id - const videoIdMatches = - record.videoId == null || record.videoId === videoId - - if (!(objectIdMatches && videoIdMatches)) { - missingVariants.push(variant.id) - } - } catch { - missingVariants.push(variant.id) - } - } + // Batch fetch all variant records from Algolia + const variantIds = variants.map((v) => v.id) + for (const variantId of variantIds) { + try { + const record = await client.getObject({ + indexName: videoVariantsIndex, + objectID: variantId + }) + const objectIdMatches = record.objectID === variantId + const videoIdMatches = record.videoId === videoId + + if (!(objectIdMatches && videoIdMatches)) { + missingVariants.push(variantId) + } + } catch (error) { + // Log error for debugging, treat as missing + console.error(`Failed to fetch Algolia record for variant ${variantId}:`, error) + missingVariants.push(variantId) + } + }
1241-1245: Simplify the Promise.all pattern.The inner
async/awaitis redundant sinceupdateVideoVariantInAlgoliaalready returns a Promise. Additionally, if any variant update fails, the entirePromise.allwill reject, potentially leaving some variants updated and others not.// Update all variants in Algolia - await Promise.all( - variants.map(async (variant) => { - await updateVideoVariantInAlgolia(variant.id) - }) - ) + await Promise.all( + variants.map((variant) => updateVideoVariantInAlgolia(variant.id)) + )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
libs/shared/gql/src/__generated__/graphql-env.d.tsis excluded by!**/__generated__/**
📒 Files selected for processing (7)
apis/api-gateway/schema.graphql(3 hunks)apis/api-media/schema.graphql(3 hunks)apis/api-media/src/lib/algolia/algoliaVideoCheck/algoliaVideoCheck.ts(1 hunks)apis/api-media/src/lib/algolia/algoliaVideoCheck/index.ts(1 hunks)apis/api-media/src/schema/video/video.ts(4 hunks)apis/api-media/src/schema/videoVariant/videoVariant.ts(1 hunks)apps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx(6 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/base.mdc)
**/*.{ts,tsx,js,jsx}: Use early returns whenever possible to make the code more readable.
Use descriptive variable and function/const names.
Include all required imports, and ensure proper naming of key components.
Files:
apis/api-media/src/lib/algolia/algoliaVideoCheck/index.tsapis/api-media/src/lib/algolia/algoliaVideoCheck/algoliaVideoCheck.tsapis/api-media/src/schema/video/video.tsapps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsxapis/api-media/src/schema/videoVariant/videoVariant.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/base.mdc)
Define a type if possible.
Files:
apis/api-media/src/lib/algolia/algoliaVideoCheck/index.tsapis/api-media/src/lib/algolia/algoliaVideoCheck/algoliaVideoCheck.tsapis/api-media/src/schema/video/video.tsapps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsxapis/api-media/src/schema/videoVariant/videoVariant.ts
apps/**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/apps.mdc)
apps/**/*.{js,jsx,ts,tsx}: Always use MUI over HTML elements; avoid using CSS or tags.
Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.
Files:
apps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx
🧠 Learnings (11)
📚 Learning: 2025-12-03T15:21:24.876Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/resources/AGENTS.md:0-0
Timestamp: 2025-12-03T15:21:24.876Z
Learning: Applies to apps/resources/src/components/**/*Video*.{ts,tsx} : Components like `VideoContentHero` depend on the full provider stack (VideoProvider, WatchProvider, PlayerProvider) plus video.js and mux metadata; preserve existing contracts for autoplay, subtitles, and analytics
Applied to files:
apis/api-media/src/lib/algolia/algoliaVideoCheck/index.tsapis/api-media/src/lib/algolia/algoliaVideoCheck/algoliaVideoCheck.tsapis/api-media/src/schema/video/video.tsapps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsxapis/api-media/src/schema/videoVariant/videoVariant.ts
📚 Learning: 2025-09-19T18:48:41.906Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/watch/AGENTS.md:0-0
Timestamp: 2025-09-19T18:48:41.906Z
Learning: Applies to apps/watch/src/**/index.ts : Export all components via index.ts files in their folders
Applied to files:
apis/api-media/src/lib/algolia/algoliaVideoCheck/index.ts
📚 Learning: 2025-12-03T15:21:24.876Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/resources/AGENTS.md:0-0
Timestamp: 2025-12-03T15:21:24.876Z
Learning: Applies to apps/resources/src/**/index.ts : Export all components through index.ts files
Applied to files:
apis/api-media/src/lib/algolia/algoliaVideoCheck/index.ts
📚 Learning: 2025-12-03T15:21:24.876Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/resources/AGENTS.md:0-0
Timestamp: 2025-12-03T15:21:24.876Z
Learning: Applies to apps/resources/src/**/*.{ts,tsx} : Apollo hooks should use generated types alongside colocated documents; `useVideoChildren` is the reference pattern
Applied to files:
apis/api-media/src/schema/video/video.tsapps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx
📚 Learning: 2025-09-19T18:48:41.906Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/watch/AGENTS.md:0-0
Timestamp: 2025-09-19T18:48:41.906Z
Learning: Applies to apps/watch/src/libs/useVideoChildren/useVideoChildren.ts : Use Apollo hooks with generated types and colocated documents; follow useVideoChildren pattern
Applied to files:
apis/api-media/src/schema/video/video.tsapps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx
📚 Learning: 2025-03-02T23:04:09.558Z
Learnt from: tataihono
Repo: JesusFilm/core PR: 5390
File: apis/api-media/src/workers/bigQuery/importers/shortLinks/shortLinks.spec.ts:1-1
Timestamp: 2025-03-02T23:04:09.558Z
Learning: Always ignore ESLint warnings (import/no-useless-path-segments) for Prisma client imports using the format `.prisma/api-media-client` instead of `./.prisma/api-media-client`. This is an intentional pattern in the codebase.
Applied to files:
apis/api-media/src/schema/video/video.ts
📚 Learning: 2025-03-02T23:04:53.192Z
Learnt from: tataihono
Repo: JesusFilm/core PR: 5390
File: apis/api-media/src/workers/bigQuery/importers/shortLinks/shortLinks.ts:4-4
Timestamp: 2025-03-02T23:04:53.192Z
Learning: Always ignore ESLint warnings about Prisma client import paths. The import path `.prisma/api-media-client` should not be changed to `./.prisma/api-media-client` despite ESLint flagging it as an error with the rule "import/no-useless-path-segments".
Applied to files:
apis/api-media/src/schema/video/video.ts
📚 Learning: 2025-08-18T17:23:02.876Z
Learnt from: tanflem
Repo: JesusFilm/core PR: 7464
File: apis/api-media/src/workers/processVideoUploads/service/service.ts:300-303
Timestamp: 2025-08-18T17:23:02.876Z
Learning: In the Video GraphQL schema, the slug field is defined as nullable: false with a resolver that returns slug ?? '', meaning it will never be null but could be an empty string if the underlying data is null/undefined.
Applied to files:
apis/api-media/src/schema/video/video.ts
📚 Learning: 2025-08-12T00:53:19.148Z
Learnt from: mikeallisonJS
Repo: JesusFilm/core PR: 7345
File: apis/api-journeys-modern/src/schema/block/inputs/blocksFilter.ts:3-8
Timestamp: 2025-08-12T00:53:19.148Z
Learning: The JesusFilm/core project has a policy of not updating existing GraphQL field names, even for consistency improvements, to maintain API stability and backward compatibility.
Applied to files:
apis/api-gateway/schema.graphql
📚 Learning: 2025-09-19T18:48:41.906Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/watch/AGENTS.md:0-0
Timestamp: 2025-09-19T18:48:41.906Z
Learning: Applies to apps/watch/**/*.{tsx} : Maintain high visual polish using Tailwind (typography, spacing, animations)
Applied to files:
apps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx
📚 Learning: 2025-09-19T18:48:41.906Z
Learnt from: CR
Repo: JesusFilm/core PR: 0
File: apps/watch/AGENTS.md:0-0
Timestamp: 2025-09-19T18:48:41.906Z
Learning: Applies to apps/watch/**/*.{tsx} : Keep browser-only logic minimal and isolated (media controls, complex form state, browser APIs)
Applied to files:
apps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx
🧬 Code graph analysis (4)
apis/api-media/src/lib/algolia/algoliaVideoCheck/algoliaVideoCheck.ts (3)
apis/api-media/src/lib/algolia/algoliaVideoCheck/index.ts (2)
checkVideoInAlgolia(2-2)checkVideoVariantsInAlgolia(3-3)apis/api-media/src/lib/algolia/algoliaClient.ts (1)
getAlgoliaClient(4-16)apis/api-gateway/src/logger.ts (1)
error(34-37)
apis/api-media/src/schema/video/video.ts (3)
apis/api-media/src/lib/algolia/algoliaClient.ts (1)
getAlgoliaClient(4-16)apis/api-media/src/lib/algolia/algoliaVideoUpdate/algoliaVideoUpdate.ts (1)
updateVideoInAlgolia(8-231)apis/api-media/src/lib/algolia/algoliaVideoVariantUpdate/algoliaVideoVariantUpdate.ts (1)
updateVideoVariantInAlgolia(18-135)
apps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx (1)
apis/api-journeys-modern/src/lib/graphql/subgraphGraphql.ts (1)
graphql(5-7)
apis/api-media/src/schema/videoVariant/videoVariant.ts (1)
apis/api-media/src/schema/video/lib/updateAvailableLanguages.ts (1)
updateParentCollectionLanguages(164-186)
🔇 Additional comments (7)
apis/api-media/src/lib/algolia/algoliaVideoCheck/index.ts (1)
1-4: Re-export surface looks goodCentralizing
checkVideoInAlgoliaandcheckVideoVariantsInAlgoliathrough this index is clean and matches the existing index.ts export pattern.apps/videos-admin/src/app/(dashboard)/videos/[videoId]/troubleshooting/page.tsx (1)
32-67: Algolia troubleshooting operations and handlers are wired cleanlyThe new Algolia queries/mutations, Apollo hooks, and
handle*callbacks are all typed, consistently named, and reuse the existing troubleshooting patterns (lazy queries, refetching after mutations, and MUI-only UI). Nothing blocking here.Also applies to: 90-145, 154-169
apis/api-gateway/schema.graphql (1)
515-517: Gateway Algolia schema additions look consistent with the media subgraphThe new Algolia mutations, queries, and result types are correctly wired to
API_MEDIAvia@join__field/@join__type, and their shapes match the media service schema and UI usage. This should compose cleanly in the supergraph.Also applies to: 909-910, 2613-2629
apis/api-media/schema.graphql (1)
49-66: Algolia check/result types and operations are well-shaped and aligned with gateway/UIThe new result types and the
updateVideo*AlgoliaIndexmutations /checkVideo*InAlgoliaqueries fit cleanly into the existing media schema and match the gateway schema and troubleshooting page expectations. The nullable fields (ok, lists, URLs) give you flexibility to represent partial/failed checks without breaking clients.Also applies to: 271-272, 662-663
apis/api-media/src/schema/video/video.ts (3)
12-14: LGTM!The new imports for
getAlgoliaClientandupdateVideoVariantInAlgoliaare correctly added and required for the new Algolia troubleshooting functionality.
59-106: LGTM!The GraphQL object refs are well-structured with appropriate nullable fields and correctly use the Pothos builder pattern for type definitions.
1203-1222: LGTM!The
updateVideoAlgoliaIndexmutation is properly implemented with video existence validation before updating. The error will propagate to the caller ifupdateVideoInAlgoliafails, which is appropriate for an explicit troubleshooting action.
apis/api-media/src/lib/algolia/algoliaVideoCheck/algoliaVideoCheck.ts
Outdated
Show resolved
Hide resolved
|
I see you added the "on stage" label, I'll get this merged to the stage branch! |
|
Merge conflict attempting to merge this into stage. Please fix manually. |
…nt-algolia-troubleshooting
|
Merge conflict attempting to merge this into stage. Please fix manually. |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run resources-e2e:e2e |
❌ Failed | 4m 10s | View ↗ |
nx run journeys-e2e:e2e |
✅ Succeeded | 22s | View ↗ |
nx run journeys-admin-e2e:e2e |
✅ Succeeded | 4m 6s | View ↗ |
nx run watch-e2e:e2e |
✅ Succeeded | 12s | View ↗ |
nx run videos-admin-e2e:e2e |
✅ Succeeded | 5s | View ↗ |
nx run short-links-e2e:e2e |
✅ Succeeded | 3s | View ↗ |
nx run-many --target=vercel-alias --projects=re... |
✅ Succeeded | 2s | View ↗ |
nx run-many --target=upload-sourcemaps --projec... |
✅ Succeeded | 9s | View ↗ |
Additional runs (16) |
✅ Succeeded | ... | View ↗ |
☁️ Nx Cloud last updated this comment at 2025-12-09 23:40:19 UTC
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
…nt-algolia-troubleshooting
…nt-algolia-troubleshooting
…roubleshooting' into tannerfleming/vmt-190-frontend-video-managment-algolia-troubleshooting
|
Found 1 test failure on Blacksmith runners: Failure
|
…roubleshooting' into tannerfleming/vmt-190-frontend-video-managment-algolia-troubleshooting
|
Merge conflict attempting to merge this into stage. Please fix manually. |
…roubleshooting' into tannerfleming/vmt-190-frontend-video-managment-algolia-troubleshooting
|
Merge conflict attempting to merge this into stage. Please fix manually. |
…roubleshooting' into tannerfleming/vmt-190-frontend-video-managment-algolia-troubleshooting
|
Merge conflict attempting to merge this into stage. Please fix manually. |
…roubleshooting' into tannerfleming/vmt-190-frontend-video-managment-algolia-troubleshooting
|
Merge conflict attempting to merge this into stage. Please fix manually. |
|
Merge conflict attempting to merge this into stage. Please fix manually. |

Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.