Skip to content

Commit 3d00734

Browse files
authored
fix: Extend recipe scrape timeout (#567)
1 parent 4bc3337 commit 3d00734

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

backend/app/service/recipe_scraping.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,13 @@ def scrape(url: str, household: Household) -> dict | None:
154154
return scrapeKitchenOwl(
155155
url, "https://app.kitchenowl.org/api", int(kitchenowlMatch.group(2))
156156
)
157+
if 'http' not in url:
158+
url = "http://" + url
157159

158-
res = requests.get(url=url)
160+
try:
161+
res = requests.get(url=url)
162+
except:
163+
return None
159164
if res.status_code != requests.codes.ok:
160165
return None
161166

kitchenowl/lib/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
}
3939
},
4040
"@address": {},
41+
"@analysingWebsite": {},
4142
"@admin": {},
4243
"@appDescription": {},
4344
"@appTitle": {
@@ -189,6 +190,7 @@
189190
"name": {}
190191
}
191192
},
193+
"@longerThanExpected": {},
192194
"@longPressToReorder": {},
193195
"@markAsPaid": {},
194196
"@mealPlanner": {},
@@ -387,6 +389,7 @@
387389
"addedBy": "Added by {name}",
388390
"address": "Address",
389391
"admin": "Admin",
392+
"analysingWebsite": "Analysing website...",
390393
"appDescription": "KitchenOwl helps you organize your grocery life.",
391394
"appTitle": "KitchenOwl",
392395
"back": "Back",
@@ -492,6 +495,7 @@
492495
"loginTo": "Login to",
493496
"logout": "Logout",
494497
"logoutName": "Logout {name}",
498+
"longerThanExpected": "This is taking longer than expected",
495499
"longPressToReorder": "Long press to reorder",
496500
"markAsPaid": "Mark as paid",
497501
"mealPlanner": "Meal planner",

kitchenowl/lib/pages/recipe_scraper_page.dart

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,32 @@ class _RecipeScraperPageState extends State<RecipeScraperPage> {
169169
),
170170
);
171171
} else {
172-
body = const Center(child: CircularProgressIndicator());
172+
body = Center(
173+
child: Column(
174+
mainAxisAlignment: MainAxisAlignment.center,
175+
children: [
176+
CircularProgressIndicator(),
177+
const SizedBox(height: 32),
178+
Text(
179+
AppLocalizations.of(context)!.analysingWebsite,
180+
style: Theme.of(context).textTheme.headlineSmall,
181+
textAlign: TextAlign.center,
182+
),
183+
const SizedBox(height: 8),
184+
FutureBuilder(
185+
future: Future.delayed(const Duration(seconds: 15)),
186+
builder: (context, snapshot) =>
187+
snapshot.connectionState == ConnectionState.done
188+
? Text(
189+
AppLocalizations.of(context)!
190+
.longerThanExpected,
191+
textAlign: TextAlign.center,
192+
)
193+
: const SizedBox(),
194+
),
195+
],
196+
),
197+
);
173198
}
174199

175200
return Scaffold(

kitchenowl/lib/services/api/recipe.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension RecipeApi on ApiService {
99
static const baseRoute = '/recipe';
1010

1111
// ignore: constant_identifier_names
12-
static const Duration _TIMEOUT_SCRAPE = Duration(seconds: 15);
12+
static const Duration _TIMEOUT_SCRAPE = Duration(minutes: 3);
1313

1414
Future<List<Recipe>?> getRecipes(Household household) async {
1515
final res = await get(householdPath(household) + baseRoute);

0 commit comments

Comments
 (0)