Skip to content
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

fix: Extend recipe scrape timeout #567

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/app/service/recipe_scraping.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,13 @@ def scrape(url: str, household: Household) -> dict | None:
return scrapeKitchenOwl(
url, "https://app.kitchenowl.org/api", int(kitchenowlMatch.group(2))
)
if 'http' not in url:
url = "http://" + url

res = requests.get(url=url)
try:
res = requests.get(url=url)
except:
return None
if res.status_code != requests.codes.ok:
return None

Expand Down
4 changes: 4 additions & 0 deletions kitchenowl/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
}
},
"@address": {},
"@analysingWebsite": {},
"@admin": {},
"@appDescription": {},
"@appTitle": {
Expand Down Expand Up @@ -189,6 +190,7 @@
"name": {}
}
},
"@longerThanExpected": {},
"@longPressToReorder": {},
"@markAsPaid": {},
"@mealPlanner": {},
Expand Down Expand Up @@ -387,6 +389,7 @@
"addedBy": "Added by {name}",
"address": "Address",
"admin": "Admin",
"analysingWebsite": "Analysing website...",
"appDescription": "KitchenOwl helps you organize your grocery life.",
"appTitle": "KitchenOwl",
"back": "Back",
Expand Down Expand Up @@ -492,6 +495,7 @@
"loginTo": "Login to",
"logout": "Logout",
"logoutName": "Logout {name}",
"longerThanExpected": "This is taking longer than expected",
"longPressToReorder": "Long press to reorder",
"markAsPaid": "Mark as paid",
"mealPlanner": "Meal planner",
Expand Down
27 changes: 26 additions & 1 deletion kitchenowl/lib/pages/recipe_scraper_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,32 @@ class _RecipeScraperPageState extends State<RecipeScraperPage> {
),
);
} else {
body = const Center(child: CircularProgressIndicator());
body = Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
const SizedBox(height: 32),
Text(
AppLocalizations.of(context)!.analysingWebsite,
style: Theme.of(context).textTheme.headlineSmall,
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
FutureBuilder(
future: Future.delayed(const Duration(seconds: 15)),
builder: (context, snapshot) =>
snapshot.connectionState == ConnectionState.done
? Text(
AppLocalizations.of(context)!
.longerThanExpected,
textAlign: TextAlign.center,
)
: const SizedBox(),
),
],
),
);
}

return Scaffold(
Expand Down
2 changes: 1 addition & 1 deletion kitchenowl/lib/services/api/recipe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension RecipeApi on ApiService {
static const baseRoute = '/recipe';

// ignore: constant_identifier_names
static const Duration _TIMEOUT_SCRAPE = Duration(seconds: 15);
static const Duration _TIMEOUT_SCRAPE = Duration(minutes: 3);

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