mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
cached facet results
This commit is contained in:
@@ -223,12 +223,6 @@
|
||||
style="flex-grow: 1; flex-shrink: 1; flex-basis: 0"/>
|
||||
<b-input-group-append>
|
||||
<b-input-group-text style="width:85px">
|
||||
<!-- <b-form-checkbox v-model="settings.search_books_or" name="check-button"
|
||||
@change="refreshData(false)"
|
||||
class="shadow-none" tyle="width: 100%" switch>
|
||||
<span class="text-uppercase" v-if="settings.search_books_or">{{ $t('or') }}</span>
|
||||
<span class="text-uppercase" v-else>{{ $t('and') }}</span>
|
||||
</b-form-checkbox> -->
|
||||
</b-input-group-text>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
@@ -303,8 +297,7 @@ import VueCookies from 'vue-cookies'
|
||||
|
||||
Vue.use(VueCookies)
|
||||
|
||||
import {ResolveUrlMixin} from "@/utils/utils";
|
||||
import {ApiMixin} from "@/utils/utils";
|
||||
import {ApiMixin, ResolveUrlMixin} from "@/utils/utils";
|
||||
|
||||
import LoadingSpinner from "@/components/LoadingSpinner"; // is this deprecated?
|
||||
|
||||
@@ -325,7 +318,7 @@ export default {
|
||||
return {
|
||||
// this.Models and this.Actions inherited from ApiMixin
|
||||
recipes: [],
|
||||
facets: [],
|
||||
facets: {},
|
||||
meal_plans: [],
|
||||
last_viewed_recipes: [],
|
||||
|
||||
@@ -387,7 +380,6 @@ export default {
|
||||
if (this.$cookies.isKey(SETTINGS_COOKIE_NAME)) {
|
||||
this.settings = Object.assign({}, this.settings, this.$cookies.get(SETTINGS_COOKIE_NAME))
|
||||
}
|
||||
|
||||
let urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
if (urlParams.has('keyword')) {
|
||||
@@ -398,6 +390,18 @@ export default {
|
||||
this.facets.Keywords.push({'id':x, 'name': 'loading...'})
|
||||
}
|
||||
}
|
||||
this.facets.Foods = []
|
||||
for (let x of this.settings.search_foods) {
|
||||
this.facets.Foods.push({'id':x, 'name': 'loading...'})
|
||||
}
|
||||
this.facets.Keywords = []
|
||||
for (let x of this.settings.search_keywords) {
|
||||
this.facets.Keywords.push({'id':x, 'name': 'loading...'})
|
||||
}
|
||||
this.facets.Books = []
|
||||
for (let x of this.settings.search_books) {
|
||||
this.facets.Books.push({'id':x, 'name': 'loading...'})
|
||||
}
|
||||
this.loadMealPlan()
|
||||
this.refreshData(false)
|
||||
})
|
||||
@@ -457,6 +461,9 @@ export default {
|
||||
this.pagination_count = result.data.count
|
||||
|
||||
this.facets = result.data.facets
|
||||
if(this.facets?.cache_key) {
|
||||
this.getFacets(this.facets.cache_key)
|
||||
}
|
||||
this.recipes = this.removeDuplicates(result.data.results, recipe => recipe.id)
|
||||
if (!this.searchFiltered){
|
||||
// if meal plans are being shown - filter out any meal plan recipes from the recipe list
|
||||
@@ -530,6 +537,11 @@ export default {
|
||||
return [undefined, undefined]
|
||||
}
|
||||
},
|
||||
getFacets: function(hash) {
|
||||
this.genericGetAPI('api_get_facets', {hash: hash}).then((response) => {
|
||||
this.facets = {...this.facets, ...response.data.facets}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,9 @@ export const ApiMixin = {
|
||||
});
|
||||
let apiClient = new ApiApiFactory()
|
||||
return apiClient[func](...parameters)
|
||||
},
|
||||
genericGetAPI: function(url, options) {
|
||||
return axios.get(this.resolveDjangoUrl(url), {'params':options, 'emulateJSON': true})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,83 +3,83 @@
|
||||
"assets": {
|
||||
"../../templates/sw.js": {
|
||||
"name": "../../templates/sw.js",
|
||||
"path": "..\\..\\templates\\sw.js"
|
||||
"path": "../../templates/sw.js"
|
||||
},
|
||||
"js/chunk-2d0da313.js": {
|
||||
"name": "js/chunk-2d0da313.js",
|
||||
"path": "js\\chunk-2d0da313.js"
|
||||
"path": "js/chunk-2d0da313.js"
|
||||
},
|
||||
"css/chunk-vendors.css": {
|
||||
"name": "css/chunk-vendors.css",
|
||||
"path": "css\\chunk-vendors.css"
|
||||
"path": "css/chunk-vendors.css"
|
||||
},
|
||||
"js/chunk-vendors.js": {
|
||||
"name": "js/chunk-vendors.js",
|
||||
"path": "js\\chunk-vendors.js"
|
||||
"path": "js/chunk-vendors.js"
|
||||
},
|
||||
"css/cookbook_view.css": {
|
||||
"name": "css/cookbook_view.css",
|
||||
"path": "css\\cookbook_view.css"
|
||||
"path": "css/cookbook_view.css"
|
||||
},
|
||||
"js/cookbook_view.js": {
|
||||
"name": "js/cookbook_view.js",
|
||||
"path": "js\\cookbook_view.js"
|
||||
"path": "js/cookbook_view.js"
|
||||
},
|
||||
"css/edit_internal_recipe.css": {
|
||||
"name": "css/edit_internal_recipe.css",
|
||||
"path": "css\\edit_internal_recipe.css"
|
||||
"path": "css/edit_internal_recipe.css"
|
||||
},
|
||||
"js/edit_internal_recipe.js": {
|
||||
"name": "js/edit_internal_recipe.js",
|
||||
"path": "js\\edit_internal_recipe.js"
|
||||
"path": "js/edit_internal_recipe.js"
|
||||
},
|
||||
"js/import_response_view.js": {
|
||||
"name": "js/import_response_view.js",
|
||||
"path": "js\\import_response_view.js"
|
||||
"path": "js/import_response_view.js"
|
||||
},
|
||||
"css/meal_plan_view.css": {
|
||||
"name": "css/meal_plan_view.css",
|
||||
"path": "css\\meal_plan_view.css"
|
||||
"path": "css/meal_plan_view.css"
|
||||
},
|
||||
"js/meal_plan_view.js": {
|
||||
"name": "js/meal_plan_view.js",
|
||||
"path": "js\\meal_plan_view.js"
|
||||
"path": "js/meal_plan_view.js"
|
||||
},
|
||||
"css/model_list_view.css": {
|
||||
"name": "css/model_list_view.css",
|
||||
"path": "css\\model_list_view.css"
|
||||
"path": "css/model_list_view.css"
|
||||
},
|
||||
"js/model_list_view.js": {
|
||||
"name": "js/model_list_view.js",
|
||||
"path": "js\\model_list_view.js"
|
||||
"path": "js/model_list_view.js"
|
||||
},
|
||||
"js/offline_view.js": {
|
||||
"name": "js/offline_view.js",
|
||||
"path": "js\\offline_view.js"
|
||||
"path": "js/offline_view.js"
|
||||
},
|
||||
"css/recipe_search_view.css": {
|
||||
"name": "css/recipe_search_view.css",
|
||||
"path": "css\\recipe_search_view.css"
|
||||
"path": "css/recipe_search_view.css"
|
||||
},
|
||||
"js/recipe_search_view.js": {
|
||||
"name": "js/recipe_search_view.js",
|
||||
"path": "js\\recipe_search_view.js"
|
||||
"path": "js/recipe_search_view.js"
|
||||
},
|
||||
"css/recipe_view.css": {
|
||||
"name": "css/recipe_view.css",
|
||||
"path": "css\\recipe_view.css"
|
||||
"path": "css/recipe_view.css"
|
||||
},
|
||||
"js/recipe_view.js": {
|
||||
"name": "js/recipe_view.js",
|
||||
"path": "js\\recipe_view.js"
|
||||
"path": "js/recipe_view.js"
|
||||
},
|
||||
"js/supermarket_view.js": {
|
||||
"name": "js/supermarket_view.js",
|
||||
"path": "js\\supermarket_view.js"
|
||||
"path": "js/supermarket_view.js"
|
||||
},
|
||||
"js/user_file_view.js": {
|
||||
"name": "js/user_file_view.js",
|
||||
"path": "js\\user_file_view.js"
|
||||
"path": "js/user_file_view.js"
|
||||
},
|
||||
"recipe_search_view.html": {
|
||||
"name": "recipe_search_view.html",
|
||||
|
||||
Reference in New Issue
Block a user