Skip to content

Commit 070a6a5

Browse files
committed
feature: add group variants flag
1 parent 6b2c7d5 commit 070a6a5

File tree

2 files changed

+67
-11
lines changed

2 files changed

+67
-11
lines changed

frontends/dashboard/src/components/NewDatasetModal.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,59 @@ export const NewDatasetModal = (props: NewDatasetModalProps) => {
10491049
/>
10501050
</div>
10511051
</Match>
1052+
<Match
1053+
when={
1054+
crawlOptions()?.scrape_options?.type ==
1055+
"shopify"
1056+
}
1057+
>
1058+
<div class="content-center py-4 sm:grid sm:grid-cols-3 sm:items-start sm:gap-4">
1059+
<label
1060+
for="groupVariants"
1061+
class="flex h-full items-center gap-2 pt-1.5 text-sm font-medium leading-6"
1062+
>
1063+
Group Product Variants
1064+
<Tooltip
1065+
body={
1066+
<FaRegularCircleQuestion class="h-4 w-4 text-black" />
1067+
}
1068+
tooltipText="This option will ingest all variants as individual chunks and place them in groups by product id. Turning this off will only scrape 1 variant per product"
1069+
direction="right"
1070+
/>
1071+
</label>
1072+
<input
1073+
type="checkbox"
1074+
id="groupVariants"
1075+
name="groupVariants"
1076+
class="col-span-2 mt-2.5 block w-fit rounded-md border-[0.5px] border-neutral-300 bg-white px-3 text-start placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6"
1077+
checked={
1078+
crawlOptions()?.scrape_options
1079+
.group_variants ?? true
1080+
}
1081+
onChange={(e) =>
1082+
setCrawlOptions((prev) => {
1083+
if (!prev) {
1084+
console.log(e.currentTarget.value);
1085+
return {
1086+
scrape_options: {
1087+
type: "shopify",
1088+
group_variants: e.currentTarget.checked,
1089+
},
1090+
};
1091+
}
1092+
1093+
return {
1094+
...prev,
1095+
scrape_options: {
1096+
type: "shopify",
1097+
group_variants: e.currentTarget.checked,
1098+
},
1099+
};
1100+
})
1101+
}
1102+
/>
1103+
</div>
1104+
</Match>
10521105
</Switch>
10531106
</div>
10541107
</Show>

frontends/dashboard/src/pages/dataset/CrawlingSettings.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,20 @@ const RealCrawlingSettings = (props: RealCrawlingSettingsProps) => {
155155
errors.site_url = "Invalid Site URL - http(s):// required";
156156
}
157157

158-
if (!value.limit || value.limit <= 0) {
159-
errors.limit = "Limit must be greater than 0";
160-
}
161-
if (!value.max_depth) {
162-
errors.max_depth = "Max depth must be greater than 0";
163-
}
164-
if (
165-
value.scrape_options?.openapi_tag &&
166-
!value.scrape_options.openapi_schema_url
167-
) {
168-
errors.scrape_options = "OpenAPI Schema URL is required for tag";
158+
if (value.scrape_options?.type != "shopify") {
159+
if (!value.limit || value.limit <= 0) {
160+
errors.limit = "Limit must be greater than 0";
161+
}
162+
if (!value.max_depth) {
163+
errors.max_depth = "Max depth must be greater than 0";
164+
}
165+
if (
166+
value.scrape_options?.type == "openapi" &&
167+
value.scrape_options?.openapi_tag &&
168+
!value.scrape_options.openapi_schema_url
169+
) {
170+
errors.scrape_options = "OpenAPI Schema URL is required for tag";
171+
}
169172
}
170173

171174
return {

0 commit comments

Comments
 (0)