diff --git a/cookbook/helper/recipe_search.py b/cookbook/helper/recipe_search.py
index ca2707ebc..23180b0a2 100644
--- a/cookbook/helper/recipe_search.py
+++ b/cookbook/helper/recipe_search.py
@@ -22,10 +22,10 @@ def search_recipes(request, queryset, params):
search_last_viewed = int(params.get('last_viewed', 0))
if search_last_viewed > 0:
- last_viewed_recipes = ViewLog.objects.filter(created_by=request.user, space=request.space).order_by(
- '-created_at').values('recipe').distinct().all()[:search_last_viewed]
-
- return queryset.filter(pk__in=last_viewed_recipes)
+ last_viewed_recipes = ViewLog.objects.filter(created_by=request.user, space=request.space).values_list('recipe__pk', flat=True).distinct()
+ # TODO filter by created by in last two weeks and re add limit to recipe selection (after reversing the order)
+ # Distinct does not work with order by
+ return queryset.filter(pk__in=list(set(last_viewed_recipes)))
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
'django.db.backends.postgresql']:
diff --git a/vue/src/apps/RecipeSearchView/RecipeSearchView.vue b/vue/src/apps/RecipeSearchView/RecipeSearchView.vue
index b13c4e467..78feb379f 100644
--- a/vue/src/apps/RecipeSearchView/RecipeSearchView.vue
+++ b/vue/src/apps/RecipeSearchView/RecipeSearchView.vue
@@ -51,8 +51,46 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -224,23 +262,33 @@ export default {
},
mounted() {
- if (this.$cookies.isKey('search_settings')) {
- console.log('loaded cookie settings')
- this.settings = this.$cookies.get("search_settings")
- }
+ this.$nextTick(function () {
+ if (this.$cookies.isKey('search_settings')) {
+ console.log('loaded cookie settings', this.$cookies.get("search_settings"))
+ this.settings = this.$cookies.get("search_settings")
+ }
+
+ this.loadMealPlan()
+ this.loadRecentlyViewed()
+ })
this.refreshData()
-
- this.loadSpecialData()
},
watch: {
settings: {
- handler(val) {
- console.log('saved cookie settings', val)
+ handler() {
this.$cookies.set("search_settings", this.settings, -1)
},
deep: true
- }
+ },
+ 'settings.show_meal_plan': function () {
+ console.log('Test')
+ this.loadMealPlan()
+ },
+ 'settings.recently_viewed': function () {
+ console.log('RV')
+ this.loadRecentlyViewed()
+ },
},
methods: {
refreshData: function () {
@@ -271,21 +319,33 @@ export default {
this.pagination_count = result.data.count
})
},
- loadSpecialData: function () {
+ loadMealPlan: function () {
let apiClient = new ApiApiFactory()
- apiClient.listMealPlans({
- query: {
- from_date: moment().format('YYYY-MM-DD'),
- to_date: moment().format('YYYY-MM-DD')
- }
- }).then(result => {
- this.meal_plans = result.data
- })
+ if (this.settings.show_meal_plan) {
+ apiClient.listMealPlans({
+ query: {
+ from_date: moment().format('YYYY-MM-DD'),
+ to_date: moment().format('YYYY-MM-DD')
+ }
+ }).then(result => {
+ this.meal_plans = result.data
+ })
+ } else {
+ this.meal_plans = []
+ }
- apiClient.listRecipes({query: {last_viewed: 5}}).then(result => {
- this.last_viewed_recipes = result.data.results
- })
+
+ },
+ loadRecentlyViewed: function () {
+ let apiClient = new ApiApiFactory()
+ if (this.settings.recently_viewed > 0) {
+ apiClient.listRecipes({query: {last_viewed: this.settings.recently_viewed}}).then(result => {
+ this.last_viewed_recipes = result.data.results
+ })
+ } else {
+ this.last_viewed_recipes = []
+ }
},
genericSelectChanged: function (obj) {
this[obj.var] = obj.val
diff --git a/vue/src/locales/en.json b/vue/src/locales/en.json
index 54c0dc86f..63e99cebf 100644
--- a/vue/src/locales/en.json
+++ b/vue/src/locales/en.json
@@ -3,12 +3,17 @@
"all_fields_optional": "All fields are optional and can be left empty.",
"convert_internal": "Convert to internal recipe",
"show_only_internal": "Show only internal recipes",
+
+
+
"Log_Recipe_Cooking": "Log Recipe Cooking",
"External_Recipe_Image": "External Recipe Image",
"Add_to_Book": "Add to Book",
"Add_to_Shopping": "Add to Shopping",
"Add_to_Plan": "Add to Plan",
"Step_start_time": "Step start time",
+
+ "Meal_Plan": "Meal Plan",
"Select_Book": "Select Book",
"Recipe_Image": "Recipe Image",
"Import_finished": "Import finished",
@@ -18,6 +23,7 @@
"Url_Import": "Url Import",
"Reset_Search": "Reset Search",
"Recently_Viewed": "Recently Viewed",
+
"Keywords": "Keywords",
"Books": "Books",
"Proteins": "Proteins",
diff --git a/vue/webpack-stats.json b/vue/webpack-stats.json
index e3b890030..328ae6b0a 100644
--- a/vue/webpack-stats.json
+++ b/vue/webpack-stats.json
@@ -1 +1 @@
-{"status":"done","chunks":{"recipe_search_view":["js/chunk-vendors.js","js/recipe_search_view.js","recipe_search_view.84ec50602e1246c3fe35.hot-update.js"],"recipe_view":["js/chunk-vendors.js","js/recipe_view.js"],"offline_view":["js/chunk-vendors.js","js/offline_view.js"],"import_response_view":["js/chunk-vendors.js","js/import_response_view.js"]},"publicPath":"http://localhost:8080/","assets":{"js/chunk-vendors.js":{"name":"js/chunk-vendors.js","path":"js\\chunk-vendors.js","publicPath":"http://localhost:8080/js/chunk-vendors.js"},"js/import_response_view.js":{"name":"js/import_response_view.js","path":"js\\import_response_view.js","publicPath":"http://localhost:8080/js/import_response_view.js"},"js/offline_view.js":{"name":"js/offline_view.js","path":"js\\offline_view.js","publicPath":"http://localhost:8080/js/offline_view.js"},"js/recipe_search_view.js":{"name":"js/recipe_search_view.js","path":"js\\recipe_search_view.js","publicPath":"http://localhost:8080/js/recipe_search_view.js"},"js/recipe_view.js":{"name":"js/recipe_view.js","path":"js\\recipe_view.js","publicPath":"http://localhost:8080/js/recipe_view.js"},"recipe_search_view.84ec50602e1246c3fe35.hot-update.js":{"name":"recipe_search_view.84ec50602e1246c3fe35.hot-update.js","path":"recipe_search_view.84ec50602e1246c3fe35.hot-update.js","publicPath":"http://localhost:8080/recipe_search_view.84ec50602e1246c3fe35.hot-update.js"},"84ec50602e1246c3fe35.hot-update.json":{"name":"84ec50602e1246c3fe35.hot-update.json","path":"84ec50602e1246c3fe35.hot-update.json","publicPath":"http://localhost:8080/84ec50602e1246c3fe35.hot-update.json"},"recipe_search_view.html":{"name":"recipe_search_view.html","path":"recipe_search_view.html","publicPath":"http://localhost:8080/recipe_search_view.html"},"recipe_view.html":{"name":"recipe_view.html","path":"recipe_view.html","publicPath":"http://localhost:8080/recipe_view.html"},"offline_view.html":{"name":"offline_view.html","path":"offline_view.html","publicPath":"http://localhost:8080/offline_view.html"},"import_response_view.html":{"name":"import_response_view.html","path":"import_response_view.html","publicPath":"http://localhost:8080/import_response_view.html"},"manifest.json":{"name":"manifest.json","path":"manifest.json","publicPath":"http://localhost:8080/manifest.json"}}}
\ No newline at end of file
+{"status":"done","chunks":{"recipe_search_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/recipe_search_view.js"],"recipe_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/recipe_view.js"],"offline_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/offline_view.js"],"import_response_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/import_response_view.js"]},"assets":{"../../templates/sw.js":{"name":"../../templates/sw.js","path":"..\\..\\templates\\sw.js"},"css/chunk-vendors.css":{"name":"css/chunk-vendors.css","path":"css\\chunk-vendors.css"},"js/chunk-vendors.js":{"name":"js/chunk-vendors.js","path":"js\\chunk-vendors.js"},"js/import_response_view.js":{"name":"js/import_response_view.js","path":"js\\import_response_view.js"},"js/offline_view.js":{"name":"js/offline_view.js","path":"js\\offline_view.js"},"js/recipe_search_view.js":{"name":"js/recipe_search_view.js","path":"js\\recipe_search_view.js"},"js/recipe_view.js":{"name":"js/recipe_view.js","path":"js\\recipe_view.js"},"recipe_search_view.html":{"name":"recipe_search_view.html","path":"recipe_search_view.html"},"recipe_view.html":{"name":"recipe_view.html","path":"recipe_view.html"},"offline_view.html":{"name":"offline_view.html","path":"offline_view.html"},"import_response_view.html":{"name":"import_response_view.html","path":"import_response_view.html"},"manifest.json":{"name":"manifest.json","path":"manifest.json"}}}
\ No newline at end of file