Skip to content

Commit f5d4b9b

Browse files
committed
fix youtube update api
1 parent ac2214d commit f5d4b9b

3 files changed

Lines changed: 161 additions & 2 deletions

File tree

app/api/youtube/views/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function POST(request: NextRequest) {
2525
try {
2626
// Fetch up to 10 pending/inProgress youtubeUpdateTask docs
2727
const tasks = await sanityWriteClient.fetch(
28-
`*[_type == "youtubeUpdateTask" && (status == "pending" || status == "inProgress")]| order(lastChecked asc nulls first)[0...10]{ _id, targetDoc->{_id, _type, youtube}, status }`
28+
`*[_type == "youtubeUpdateTask" && (status == "pending" || status == "inProgress")]| order(lastChecked asc)[0...10]{ _id, targetDoc->{_id, _type, youtube}, status }`
2929
);
3030

3131
if (!tasks || tasks.length === 0) {

sanity/extract.json

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,141 @@
11
[
2+
{
3+
"name": "youtubeUpdateTask",
4+
"type": "document",
5+
"attributes": {
6+
"_id": {
7+
"type": "objectAttribute",
8+
"value": {
9+
"type": "string"
10+
}
11+
},
12+
"_type": {
13+
"type": "objectAttribute",
14+
"value": {
15+
"type": "string",
16+
"value": "youtubeUpdateTask"
17+
}
18+
},
19+
"_createdAt": {
20+
"type": "objectAttribute",
21+
"value": {
22+
"type": "string"
23+
}
24+
},
25+
"_updatedAt": {
26+
"type": "objectAttribute",
27+
"value": {
28+
"type": "string"
29+
}
30+
},
31+
"_rev": {
32+
"type": "objectAttribute",
33+
"value": {
34+
"type": "string"
35+
}
36+
},
37+
"targetDoc": {
38+
"type": "objectAttribute",
39+
"value": {
40+
"type": "union",
41+
"of": [
42+
{
43+
"type": "object",
44+
"attributes": {
45+
"_ref": {
46+
"type": "objectAttribute",
47+
"value": {
48+
"type": "string"
49+
}
50+
},
51+
"_type": {
52+
"type": "objectAttribute",
53+
"value": {
54+
"type": "string",
55+
"value": "reference"
56+
}
57+
},
58+
"_weak": {
59+
"type": "objectAttribute",
60+
"value": {
61+
"type": "boolean"
62+
},
63+
"optional": true
64+
}
65+
},
66+
"dereferencesTo": "post"
67+
},
68+
{
69+
"type": "object",
70+
"attributes": {
71+
"_ref": {
72+
"type": "objectAttribute",
73+
"value": {
74+
"type": "string"
75+
}
76+
},
77+
"_type": {
78+
"type": "objectAttribute",
79+
"value": {
80+
"type": "string",
81+
"value": "reference"
82+
}
83+
},
84+
"_weak": {
85+
"type": "objectAttribute",
86+
"value": {
87+
"type": "boolean"
88+
},
89+
"optional": true
90+
}
91+
},
92+
"dereferencesTo": "podcast"
93+
}
94+
]
95+
},
96+
"optional": true
97+
},
98+
"status": {
99+
"type": "objectAttribute",
100+
"value": {
101+
"type": "union",
102+
"of": [
103+
{
104+
"type": "string",
105+
"value": "pending"
106+
},
107+
{
108+
"type": "string",
109+
"value": "inProgress"
110+
},
111+
{
112+
"type": "string",
113+
"value": "completed"
114+
},
115+
{
116+
"type": "string",
117+
"value": "error"
118+
}
119+
]
120+
},
121+
"optional": true
122+
},
123+
"lastChecked": {
124+
"type": "objectAttribute",
125+
"value": {
126+
"type": "string"
127+
},
128+
"optional": true
129+
},
130+
"errorMessage": {
131+
"type": "objectAttribute",
132+
"value": {
133+
"type": "string"
134+
},
135+
"optional": true
136+
}
137+
}
138+
},
2139
{
3140
"name": "sponsor",
4141
"type": "document",

sanity/types.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@
1313
*/
1414

1515
// Source: schema.json
16+
export type YoutubeUpdateTask = {
17+
_id: string;
18+
_type: "youtubeUpdateTask";
19+
_createdAt: string;
20+
_updatedAt: string;
21+
_rev: string;
22+
targetDoc?: {
23+
_ref: string;
24+
_type: "reference";
25+
_weak?: boolean;
26+
[internalGroqTypeReferenceTo]?: "post";
27+
} | {
28+
_ref: string;
29+
_type: "reference";
30+
_weak?: boolean;
31+
[internalGroqTypeReferenceTo]?: "podcast";
32+
};
33+
status?: "pending" | "inProgress" | "completed" | "error";
34+
lastChecked?: string;
35+
errorMessage?: string;
36+
};
37+
1638
export type Sponsor = {
1739
_id: string;
1840
_type: "sponsor";
@@ -1720,7 +1742,7 @@ export type SanityAssetSourceData = {
17201742
url?: string;
17211743
};
17221744

1723-
export type AllSanitySchemaTypes = Sponsor | Lesson | Author | Post | Podcast | Guest | PodcastType | Course | Page | Settings | PodcastRssEpisode | Code | CloudinaryAssetContextCustom | CloudinaryAssetDerived | CloudinaryAsset | CloudinaryAssetContext | SanityAssistInstructionTask | SanityAssistTaskStatus | SanityAssistSchemaTypeAnnotations | SanityAssistOutputType | SanityAssistOutputField | SanityAssistInstructionContext | AssistInstructionContext | SanityAssistInstructionUserInput | SanityAssistInstructionPrompt | SanityAssistInstructionFieldRef | SanityAssistInstruction | SanityAssistSchemaTypeField | SanityImagePaletteSwatch | SanityImagePalette | SanityImageDimensions | SanityImageHotspot | SanityImageCrop | SanityFileAsset | SanityImageAsset | SanityImageMetadata | Geopoint | Slug | SanityAssetSourceData;
1745+
export type AllSanitySchemaTypes = YoutubeUpdateTask | Sponsor | Lesson | Author | Post | Podcast | Guest | PodcastType | Course | Page | Settings | PodcastRssEpisode | Code | CloudinaryAssetContextCustom | CloudinaryAssetDerived | CloudinaryAsset | CloudinaryAssetContext | SanityAssistInstructionTask | SanityAssistTaskStatus | SanityAssistSchemaTypeAnnotations | SanityAssistOutputType | SanityAssistOutputField | SanityAssistInstructionContext | AssistInstructionContext | SanityAssistInstructionUserInput | SanityAssistInstructionPrompt | SanityAssistInstructionFieldRef | SanityAssistInstruction | SanityAssistSchemaTypeField | SanityImagePaletteSwatch | SanityImagePalette | SanityImageDimensions | SanityImageHotspot | SanityImageCrop | SanityFileAsset | SanityImageAsset | SanityImageMetadata | Geopoint | Slug | SanityAssetSourceData;
17241746
export declare const internalGroqTypeReferenceTo: unique symbol;
17251747
// Source: sanity/lib/queries.ts
17261748
// Variable: docCount

0 commit comments

Comments
 (0)