autosync WIP

This commit is contained in:
vabene1111
2024-11-25 18:36:11 +01:00
parent 0485e5192b
commit d91a3080d5
41 changed files with 413 additions and 1876 deletions

View File

@@ -1238,12 +1238,13 @@ class ShoppingListEntrySerializer(WritableNestedModelSerializer):
'recipe_mealplan',
'created_by', 'created_at', 'updated_at', 'completed_at', 'delay_until'
)
read_only_fields = ('id', 'created_by', 'created_at', 'updated_at',)
read_only_fields = ('id', 'created_by', 'created_at')
class ShoppingListEntryBulkSerializer(serializers.Serializer):
ids = serializers.ListField()
checked = serializers.BooleanField()
timestamp = serializers.DateTimeField(read_only=True, required=False)
# TODO deprecate

View File

@@ -30,7 +30,9 @@ from django.http import FileResponse, HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse
from django.utils import timezone
from django.utils.dateparse import parse_datetime
from django.utils.datetime_safe import date
from django.utils.timezone import make_aware
from django.utils.translation import gettext as _
from django_scopes import scopes_disabled
from drf_spectacular.types import OpenApiTypes
@@ -111,6 +113,7 @@ from recipes.settings import DRF_THROTTLE_RECIPE_URL_IMPORT, FDC_API_KEY, GOOGLE
DateExample = OpenApiExample('Date Format', value='1972-12-05', request_only=True)
BeforeDateExample = OpenApiExample('Before Date Format', value='-1972-12-05', request_only=True)
class LoggingMixin(object):
"""
logs request counts to redis cache total/per user/
@@ -150,6 +153,7 @@ class LoggingMixin(object):
pipe.execute()
@extend_schema_view(list=extend_schema(parameters=[
OpenApiParameter(name='query', description='lookup if query string is contained within the name, case insensitive',
type=str),
@@ -187,15 +191,36 @@ class StandardFilterModelViewSet(viewsets.ModelViewSet):
class DefaultPagination(PageNumberPagination):
"""
Default pagination class to set the default and maximum page size
also annotates the current server timestamp to all results
"""
page_size = 50
page_size_query_param = 'page_size'
max_page_size = 200
def get_paginated_response(self, data):
return Response({
'count': self.page.paginator.count,
'next': self.get_next_link(),
'previous': self.get_previous_link(),
'timestamp': timezone.now().isoformat(),
'results': data,
})
def get_paginated_response_schema(self, schema):
schema = super().get_paginated_response_schema(schema)
schema['properties']['timestamp'] = {
'type': 'string',
'format': 'date-time',
}
return schema
class ExtendedRecipeMixin():
'''
"""
ExtendedRecipe annotates a queryset with recipe_image and recipe_count values
'''
"""
@classmethod
def annotate_recipe(self, queryset=None, request=None, serializer=None, tree=False):
@@ -1356,6 +1381,9 @@ class ShoppingListRecipeViewSet(LoggingMixin, viewsets.ModelViewSet):
OpenApiParameter(name='supermarket',
description=_('Returns the shopping list entries sorted by supermarket category order.'),
type=int),
OpenApiParameter(name='updated_after',
description=_('Returns only elements updated after the given timestamp in ISO 8601 format.'),
type=datetime.datetime),
]))
class ShoppingListEntryViewSet(LoggingMixin, viewsets.ModelViewSet):
queryset = ShoppingListEntry.objects
@@ -1381,12 +1409,14 @@ class ShoppingListEntryViewSet(LoggingMixin, viewsets.ModelViewSet):
'list_recipe__mealplan__recipe',
).distinct().all()
updated_after = self.request.query_params.get('updated_after', None)
if pk := self.request.query_params.getlist('id', []):
self.queryset = self.queryset.filter(food__id__in=[int(i) for i in pk])
if 'checked' in self.request.query_params:
return shopping_helper(self.queryset, self.request)
elif not self.detail:
elif not self.detail and not updated_after:
today_start = timezone.now().replace(hour=0, minute=0, second=0)
week_ago = today_start - datetime.timedelta(
days=min(self.request.user.userpreference.shopping_recent_days, 14))
@@ -1395,11 +1425,20 @@ class ShoppingListEntryViewSet(LoggingMixin, viewsets.ModelViewSet):
try:
last_autosync = self.request.query_params.get('last_autosync', None)
if last_autosync:
print('DEPRECATION WARNING: using last_autosync is deprecated and will be removed in future versions, please use updated_after')
last_autosync = datetime.datetime.fromtimestamp(int(last_autosync) / 1000, datetime.timezone.utc)
self.queryset = self.queryset.filter(updated_at__gte=last_autosync)
except Exception:
traceback.print_exc()
try:
if updated_after:
updated_after = parse_datetime(updated_after)
print('adding filter updated_after', updated_after)
self.queryset = self.queryset.filter(updated_at__gte=updated_after)
except Exception:
traceback.print_exc()
# TODO once old shopping list is removed this needs updated to sharing users in preferences
if self.detail:
return self.queryset
@@ -1413,12 +1452,15 @@ class ShoppingListEntryViewSet(LoggingMixin, viewsets.ModelViewSet):
if serializer.is_valid():
print(serializer.validated_data)
bulk_entries = ShoppingListEntry.objects.filter(Q(created_by=self.request.user)
| Q(
created_by__in=list(self.request.user.get_shopping_share()))).filter(space=request.space,
id__in=serializer.validated_data[
'ids'])
bulk_entries.update(checked=(checked := serializer.validated_data['checked']), updated_at=timezone.now(), )
bulk_entries = ShoppingListEntry.objects.filter(
Q(created_by=self.request.user) | Q(created_by__in=list(self.request.user.get_shopping_share()))
).filter(
space=request.space, id__in=serializer.validated_data['ids']
)
update_timestamp = timezone.now()
bulk_entries.update(checked=(checked := serializer.validated_data['checked']), updated_at=update_timestamp, )
serializer.validated_data['timestamp'] = update_timestamp
# update the onhand for food if shopping_add_onhand is True
if request.user.userpreference.shopping_add_onhand:
@@ -1430,7 +1472,7 @@ class ShoppingListEntryViewSet(LoggingMixin, viewsets.ModelViewSet):
for f in foods:
f.onhand_users.remove(*request.user.userpreference.shopping_share.all(), request.user)
return Response(serializer.data)
return Response(serializer.validated_data)
else:
return Response(serializer.errors, 400)

View File

@@ -1,6 +1,8 @@
<template>
<v-tabs v-model="currentTab">
<v-tab value="shopping"><i class="fas fa-shopping-cart fa-fw"></i> <span class="d-none d-md-block ms-1">{{ $t('Shopping_list') }}</span></v-tab>
<v-tab value="shopping"><i class="fas fa-fw"
:class="{'fa-circle-notch fa-spin':useShoppingStore().currentlyUpdating, 'fa-shopping-cart ': !useShoppingStore().currentlyUpdating}"></i> <span
class="d-none d-md-block ms-1">{{ $t('Shopping_list') }}</span></v-tab>
<v-tab value="recipes"><i class="fas fa-book fa-fw"></i> <span class="d-none d-md-block ms-1">{{ $t('Recipes') }}</span></v-tab>
<v-menu :close-on-content-click="false">
@@ -32,7 +34,8 @@
<v-switch color="primary" hide-details :label="$t('ShowDelayed')" v-model="useUserPreferenceStore().deviceSettings.shopping_show_delayed_entries"></v-switch>
</v-list-item>
<v-list-item>
<v-switch color="primary" hide-details :label="$t('ShowRecentlyCompleted')" v-model="useUserPreferenceStore().deviceSettings.shopping_show_checked_entries"></v-switch>
<v-switch color="primary" hide-details :label="$t('ShowRecentlyCompleted')"
v-model="useUserPreferenceStore().deviceSettings.shopping_show_checked_entries"></v-switch>
</v-list-item>
</v-list>
</v-menu>
@@ -66,7 +69,7 @@
<template v-for="[i, value] in category.foods" :key="value.food.id">
<shopping-line-item :shopping-list-food="value" :entries="Array.from(value.entries.values())"
@clicked="args => {shoppingLineItemDialog = true; shoppingLineItemDialogFood = value; console.log('SETTING ITEMS')}"></shopping-line-item>
@clicked="args => {shoppingLineItemDialog = true; shoppingLineItemDialogFood = value;}"></shopping-line-item>
</template>
</template>
@@ -74,6 +77,22 @@
</v-list>
</v-col>
</v-row>
<v-row>
<v-col cols="4">
<v-card>
<v-card-title>Auto Sync Debug</v-card-title>
<v-card-text>
<v-list>
<v-list-item>currentlyUpdating: {{ useShoppingStore().currentlyUpdating }}</v-list-item>
<v-list-item>hasFocus: {{ useShoppingStore().autoSyncHasFocus }}</v-list-item>
<v-list-item>autoSyncTimeoutId: {{ useShoppingStore().autoSyncTimeoutId }}</v-list-item>
<v-list-item>autoSyncLastTimestamp: {{ useShoppingStore().autoSyncLastTimestamp }}</v-list-item>
</v-list>
</v-card-text>
</v-card>
</v-col>
</v-row>
</v-container>
</v-window-item>
<v-window-item value="recipes">
@@ -134,7 +153,13 @@ const groupingOptionsItems = computed(() => {
})
onMounted(() => {
addEventListener("visibilitychange", (event) => {
useShoppingStore().autoSyncHasFocus = (document.visibilityState === 'visible')
});
useShoppingStore().refreshFromAPI()
autoSyncLoop()
})
/**
@@ -160,6 +185,23 @@ function addIngredient() {
})
}
/**
* run the autosync function in a loop
*/
function autoSyncLoop() {
// this should not happen in production but sometimes in development with HMR
clearTimeout(useShoppingStore().autoSyncTimeoutId)
let timeout = Math.max(useUserPreferenceStore().userSettings.shoppingAutoSync!, 1) * 1000 // if disabled (shopping_auto_sync=0) check again after 1 second if enabled
useShoppingStore().autoSyncTimeoutId = setTimeout(() => {
if (useUserPreferenceStore().userSettings.shoppingAutoSync! > 0) {
useShoppingStore().autoSync()
}
autoSyncLoop()
}, timeout)
}
</script>
<style scoped>

View File

@@ -7,8 +7,6 @@ models/AccessToken.ts
models/AuthToken.ts
models/AutoMealPlan.ts
models/Automation.ts
models/AutomationTypeEnum.ts
models/BaseUnitEnum.ts
models/BookmarkletImport.ts
models/BookmarkletImportList.ts
models/ConnectorConfigConfig.ts
@@ -34,16 +32,6 @@ models/MealPlan.ts
models/MealType.ts
models/MethodEnum.ts
models/NutritionInformation.ts
models/OpenDataCategory.ts
models/OpenDataConversion.ts
models/OpenDataFood.ts
models/OpenDataFoodProperty.ts
models/OpenDataProperty.ts
models/OpenDataStore.ts
models/OpenDataStoreCategory.ts
models/OpenDataUnit.ts
models/OpenDataUnitTypeEnum.ts
models/OpenDataVersion.ts
models/PaginatedAutomationList.ts
models/PaginatedBookmarkletImportListList.ts
models/PaginatedCookLogList.ts
@@ -90,13 +78,6 @@ models/PatchedInviteLink.ts
models/PatchedKeyword.ts
models/PatchedMealPlan.ts
models/PatchedMealType.ts
models/PatchedOpenDataCategory.ts
models/PatchedOpenDataConversion.ts
models/PatchedOpenDataFood.ts
models/PatchedOpenDataProperty.ts
models/PatchedOpenDataStore.ts
models/PatchedOpenDataUnit.ts
models/PatchedOpenDataVersion.ts
models/PatchedProperty.ts
models/PatchedPropertyType.ts
models/PatchedRecipe.ts
@@ -143,6 +124,7 @@ models/SupermarketCategoryRelation.ts
models/Sync.ts
models/SyncLog.ts
models/ThemeEnum.ts
models/TypeEnum.ts
models/Unit.ts
models/UnitConversion.ts
models/User.ts

File diff suppressed because it is too large Load Diff

View File

@@ -13,12 +13,12 @@
*/
import { mapValues } from '../runtime';
import type { AutomationTypeEnum } from './AutomationTypeEnum';
import type { TypeEnum } from './TypeEnum';
import {
AutomationTypeEnumFromJSON,
AutomationTypeEnumFromJSONTyped,
AutomationTypeEnumToJSON,
} from './AutomationTypeEnum';
TypeEnumFromJSON,
TypeEnumFromJSONTyped,
TypeEnumToJSON,
} from './TypeEnum';
/**
*
@@ -34,10 +34,10 @@ export interface Automation {
id?: number;
/**
*
* @type {AutomationTypeEnum}
* @type {TypeEnum}
* @memberof Automation
*/
type: AutomationTypeEnum;
type: TypeEnum;
/**
*
* @type {string}
@@ -110,7 +110,7 @@ export function AutomationFromJSONTyped(json: any, ignoreDiscriminator: boolean)
return {
'id': json['id'] == null ? undefined : json['id'],
'type': AutomationTypeEnumFromJSON(json['type']),
'type': TypeEnumFromJSON(json['type']),
'name': json['name'] == null ? undefined : json['name'],
'description': json['description'] == null ? undefined : json['description'],
'param1': json['param_1'] == null ? undefined : json['param_1'],
@@ -129,7 +129,7 @@ export function AutomationToJSON(value?: Omit<Automation, 'created_by'> | null):
return {
'id': value['id'],
'type': AutomationTypeEnumToJSON(value['type']),
'type': TypeEnumToJSON(value['type']),
'name': value['name'],
'description': value['description'],
'param_1': value['param1'],

View File

@@ -50,6 +50,12 @@ export interface PaginatedAutomationList {
* @memberof PaginatedAutomationList
*/
results: Array<Automation>;
/**
*
* @type {Date}
* @memberof PaginatedAutomationList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedAutomationListFromJSONTyped(json: any, ignoreDiscrimina
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(AutomationFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedAutomationListToJSON(value?: PaginatedAutomationList |
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(AutomationToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedBookmarkletImportListList {
* @memberof PaginatedBookmarkletImportListList
*/
results: Array<BookmarkletImportList>;
/**
*
* @type {Date}
* @memberof PaginatedBookmarkletImportListList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedBookmarkletImportListListFromJSONTyped(json: any, ignor
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(BookmarkletImportListFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedBookmarkletImportListListToJSON(value?: PaginatedBookma
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(BookmarkletImportListToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedCookLogList {
* @memberof PaginatedCookLogList
*/
results: Array<CookLog>;
/**
*
* @type {Date}
* @memberof PaginatedCookLogList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedCookLogListFromJSONTyped(json: any, ignoreDiscriminator
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(CookLogFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedCookLogListToJSON(value?: PaginatedCookLogList | null):
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(CookLogToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedCustomFilterList {
* @memberof PaginatedCustomFilterList
*/
results: Array<CustomFilter>;
/**
*
* @type {Date}
* @memberof PaginatedCustomFilterList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedCustomFilterListFromJSONTyped(json: any, ignoreDiscrimi
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(CustomFilterFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedCustomFilterListToJSON(value?: PaginatedCustomFilterLis
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(CustomFilterToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedExportLogList {
* @memberof PaginatedExportLogList
*/
results: Array<ExportLog>;
/**
*
* @type {Date}
* @memberof PaginatedExportLogList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedExportLogListFromJSONTyped(json: any, ignoreDiscriminat
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(ExportLogFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedExportLogListToJSON(value?: PaginatedExportLogList | nu
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(ExportLogToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedFoodList {
* @memberof PaginatedFoodList
*/
results: Array<Food>;
/**
*
* @type {Date}
* @memberof PaginatedFoodList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedFoodListFromJSONTyped(json: any, ignoreDiscriminator: b
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(FoodFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedFoodListToJSON(value?: PaginatedFoodList | null): any {
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(FoodToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedImportLogList {
* @memberof PaginatedImportLogList
*/
results: Array<ImportLog>;
/**
*
* @type {Date}
* @memberof PaginatedImportLogList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedImportLogListFromJSONTyped(json: any, ignoreDiscriminat
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(ImportLogFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedImportLogListToJSON(value?: PaginatedImportLogList | nu
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(ImportLogToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedIngredientList {
* @memberof PaginatedIngredientList
*/
results: Array<Ingredient>;
/**
*
* @type {Date}
* @memberof PaginatedIngredientList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedIngredientListFromJSONTyped(json: any, ignoreDiscrimina
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(IngredientFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedIngredientListToJSON(value?: PaginatedIngredientList |
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(IngredientToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedInviteLinkList {
* @memberof PaginatedInviteLinkList
*/
results: Array<InviteLink>;
/**
*
* @type {Date}
* @memberof PaginatedInviteLinkList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedInviteLinkListFromJSONTyped(json: any, ignoreDiscrimina
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(InviteLinkFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedInviteLinkListToJSON(value?: PaginatedInviteLinkList |
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(InviteLinkToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedKeywordList {
* @memberof PaginatedKeywordList
*/
results: Array<Keyword>;
/**
*
* @type {Date}
* @memberof PaginatedKeywordList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedKeywordListFromJSONTyped(json: any, ignoreDiscriminator
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(KeywordFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedKeywordListToJSON(value?: PaginatedKeywordList | null):
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(KeywordToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedMealPlanList {
* @memberof PaginatedMealPlanList
*/
results: Array<MealPlan>;
/**
*
* @type {Date}
* @memberof PaginatedMealPlanList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedMealPlanListFromJSONTyped(json: any, ignoreDiscriminato
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(MealPlanFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedMealPlanListToJSON(value?: PaginatedMealPlanList | null
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(MealPlanToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedMealTypeList {
* @memberof PaginatedMealTypeList
*/
results: Array<MealType>;
/**
*
* @type {Date}
* @memberof PaginatedMealTypeList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedMealTypeListFromJSONTyped(json: any, ignoreDiscriminato
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(MealTypeFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedMealTypeListToJSON(value?: PaginatedMealTypeList | null
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(MealTypeToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedPropertyList {
* @memberof PaginatedPropertyList
*/
results: Array<Property>;
/**
*
* @type {Date}
* @memberof PaginatedPropertyList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedPropertyListFromJSONTyped(json: any, ignoreDiscriminato
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(PropertyFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedPropertyListToJSON(value?: PaginatedPropertyList | null
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(PropertyToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedPropertyTypeList {
* @memberof PaginatedPropertyTypeList
*/
results: Array<PropertyType>;
/**
*
* @type {Date}
* @memberof PaginatedPropertyTypeList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedPropertyTypeListFromJSONTyped(json: any, ignoreDiscrimi
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(PropertyTypeFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedPropertyTypeListToJSON(value?: PaginatedPropertyTypeLis
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(PropertyTypeToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedRecipeBookEntryList {
* @memberof PaginatedRecipeBookEntryList
*/
results: Array<RecipeBookEntry>;
/**
*
* @type {Date}
* @memberof PaginatedRecipeBookEntryList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedRecipeBookEntryListFromJSONTyped(json: any, ignoreDiscr
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(RecipeBookEntryFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedRecipeBookEntryListToJSON(value?: PaginatedRecipeBookEn
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(RecipeBookEntryToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedRecipeBookList {
* @memberof PaginatedRecipeBookList
*/
results: Array<RecipeBook>;
/**
*
* @type {Date}
* @memberof PaginatedRecipeBookList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedRecipeBookListFromJSONTyped(json: any, ignoreDiscrimina
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(RecipeBookFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedRecipeBookListToJSON(value?: PaginatedRecipeBookList |
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(RecipeBookToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedShoppingListEntryList {
* @memberof PaginatedShoppingListEntryList
*/
results: Array<ShoppingListEntry>;
/**
*
* @type {Date}
* @memberof PaginatedShoppingListEntryList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedShoppingListEntryListFromJSONTyped(json: any, ignoreDis
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(ShoppingListEntryFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedShoppingListEntryListToJSON(value?: PaginatedShoppingLi
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(ShoppingListEntryToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedShoppingListRecipeList {
* @memberof PaginatedShoppingListRecipeList
*/
results: Array<ShoppingListRecipe>;
/**
*
* @type {Date}
* @memberof PaginatedShoppingListRecipeList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedShoppingListRecipeListFromJSONTyped(json: any, ignoreDi
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(ShoppingListRecipeFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedShoppingListRecipeListToJSON(value?: PaginatedShoppingL
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(ShoppingListRecipeToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedSpaceList {
* @memberof PaginatedSpaceList
*/
results: Array<Space>;
/**
*
* @type {Date}
* @memberof PaginatedSpaceList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedSpaceListFromJSONTyped(json: any, ignoreDiscriminator:
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(SpaceFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedSpaceListToJSON(value?: PaginatedSpaceList | null): any
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(SpaceToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedStepList {
* @memberof PaginatedStepList
*/
results: Array<Step>;
/**
*
* @type {Date}
* @memberof PaginatedStepList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedStepListFromJSONTyped(json: any, ignoreDiscriminator: b
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(StepFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedStepListToJSON(value?: PaginatedStepList | null): any {
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(StepToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedSupermarketCategoryList {
* @memberof PaginatedSupermarketCategoryList
*/
results: Array<SupermarketCategory>;
/**
*
* @type {Date}
* @memberof PaginatedSupermarketCategoryList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedSupermarketCategoryListFromJSONTyped(json: any, ignoreD
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(SupermarketCategoryFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedSupermarketCategoryListToJSON(value?: PaginatedSupermar
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(SupermarketCategoryToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedSupermarketCategoryRelationList {
* @memberof PaginatedSupermarketCategoryRelationList
*/
results: Array<SupermarketCategoryRelation>;
/**
*
* @type {Date}
* @memberof PaginatedSupermarketCategoryRelationList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedSupermarketCategoryRelationListFromJSONTyped(json: any,
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(SupermarketCategoryRelationFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedSupermarketCategoryRelationListToJSON(value?: Paginated
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(SupermarketCategoryRelationToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedSupermarketList {
* @memberof PaginatedSupermarketList
*/
results: Array<Supermarket>;
/**
*
* @type {Date}
* @memberof PaginatedSupermarketList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedSupermarketListFromJSONTyped(json: any, ignoreDiscrimin
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(SupermarketFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedSupermarketListToJSON(value?: PaginatedSupermarketList
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(SupermarketToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedSyncList {
* @memberof PaginatedSyncList
*/
results: Array<Sync>;
/**
*
* @type {Date}
* @memberof PaginatedSyncList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedSyncListFromJSONTyped(json: any, ignoreDiscriminator: b
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(SyncFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedSyncListToJSON(value?: PaginatedSyncList | null): any {
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(SyncToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedSyncLogList {
* @memberof PaginatedSyncLogList
*/
results: Array<SyncLog>;
/**
*
* @type {Date}
* @memberof PaginatedSyncLogList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedSyncLogListFromJSONTyped(json: any, ignoreDiscriminator
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(SyncLogFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedSyncLogListToJSON(value?: PaginatedSyncLogList | null):
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(SyncLogToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedUnitConversionList {
* @memberof PaginatedUnitConversionList
*/
results: Array<UnitConversion>;
/**
*
* @type {Date}
* @memberof PaginatedUnitConversionList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedUnitConversionListFromJSONTyped(json: any, ignoreDiscri
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(UnitConversionFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedUnitConversionListToJSON(value?: PaginatedUnitConversio
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(UnitConversionToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedUnitList {
* @memberof PaginatedUnitList
*/
results: Array<Unit>;
/**
*
* @type {Date}
* @memberof PaginatedUnitList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedUnitListFromJSONTyped(json: any, ignoreDiscriminator: b
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(UnitFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedUnitListToJSON(value?: PaginatedUnitList | null): any {
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(UnitToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedUserFileList {
* @memberof PaginatedUserFileList
*/
results: Array<UserFile>;
/**
*
* @type {Date}
* @memberof PaginatedUserFileList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedUserFileListFromJSONTyped(json: any, ignoreDiscriminato
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(UserFileFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedUserFileListToJSON(value?: PaginatedUserFileList | null
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(UserFileToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedUserSpaceList {
* @memberof PaginatedUserSpaceList
*/
results: Array<UserSpace>;
/**
*
* @type {Date}
* @memberof PaginatedUserSpaceList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedUserSpaceListFromJSONTyped(json: any, ignoreDiscriminat
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(UserSpaceFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedUserSpaceListToJSON(value?: PaginatedUserSpaceList | nu
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(UserSpaceToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -50,6 +50,12 @@ export interface PaginatedViewLogList {
* @memberof PaginatedViewLogList
*/
results: Array<ViewLog>;
/**
*
* @type {Date}
* @memberof PaginatedViewLogList
*/
timestamp?: Date;
}
/**
@@ -75,6 +81,7 @@ export function PaginatedViewLogListFromJSONTyped(json: any, ignoreDiscriminator
'next': json['next'] == null ? undefined : json['next'],
'previous': json['previous'] == null ? undefined : json['previous'],
'results': ((json['results'] as Array<any>).map(ViewLogFromJSON)),
'timestamp': json['timestamp'] == null ? undefined : (new Date(json['timestamp'])),
};
}
@@ -88,6 +95,7 @@ export function PaginatedViewLogListToJSON(value?: PaginatedViewLogList | null):
'next': value['next'],
'previous': value['previous'],
'results': ((value['results'] as Array<any>).map(ViewLogToJSON)),
'timestamp': value['timestamp'] == null ? undefined : ((value['timestamp']).toISOString()),
};
}
// ----------------------------------------------------------------------

View File

@@ -13,12 +13,12 @@
*/
import { mapValues } from '../runtime';
import type { AutomationTypeEnum } from './AutomationTypeEnum';
import type { TypeEnum } from './TypeEnum';
import {
AutomationTypeEnumFromJSON,
AutomationTypeEnumFromJSONTyped,
AutomationTypeEnumToJSON,
} from './AutomationTypeEnum';
TypeEnumFromJSON,
TypeEnumFromJSONTyped,
TypeEnumToJSON,
} from './TypeEnum';
/**
*
@@ -34,10 +34,10 @@ export interface PatchedAutomation {
id?: number;
/**
*
* @type {AutomationTypeEnum}
* @type {TypeEnum}
* @memberof PatchedAutomation
*/
type?: AutomationTypeEnum;
type?: TypeEnum;
/**
*
* @type {string}
@@ -108,7 +108,7 @@ export function PatchedAutomationFromJSONTyped(json: any, ignoreDiscriminator: b
return {
'id': json['id'] == null ? undefined : json['id'],
'type': json['type'] == null ? undefined : AutomationTypeEnumFromJSON(json['type']),
'type': json['type'] == null ? undefined : TypeEnumFromJSON(json['type']),
'name': json['name'] == null ? undefined : json['name'],
'description': json['description'] == null ? undefined : json['description'],
'param1': json['param_1'] == null ? undefined : json['param_1'],
@@ -127,7 +127,7 @@ export function PatchedAutomationToJSON(value?: Omit<PatchedAutomation, 'created
return {
'id': value['id'],
'type': AutomationTypeEnumToJSON(value['type']),
'type': TypeEnumToJSON(value['type']),
'name': value['name'],
'description': value['description'],
'param_1': value['param1'],

View File

@@ -31,6 +31,12 @@ export interface ShoppingListEntryBulk {
* @memberof ShoppingListEntryBulk
*/
checked: boolean;
/**
*
* @type {Date}
* @memberof ShoppingListEntryBulk
*/
readonly timestamp: Date;
}
/**
@@ -39,6 +45,7 @@ export interface ShoppingListEntryBulk {
export function instanceOfShoppingListEntryBulk(value: object): value is ShoppingListEntryBulk {
if (!('ids' in value) || value['ids'] === undefined) return false;
if (!('checked' in value) || value['checked'] === undefined) return false;
if (!('timestamp' in value) || value['timestamp'] === undefined) return false;
return true;
}
@@ -54,10 +61,11 @@ export function ShoppingListEntryBulkFromJSONTyped(json: any, ignoreDiscriminato
'ids': json['ids'],
'checked': json['checked'],
'timestamp': (new Date(json['timestamp'])),
};
}
export function ShoppingListEntryBulkToJSON(value?: ShoppingListEntryBulk | null): any {
export function ShoppingListEntryBulkToJSON(value?: Omit<ShoppingListEntryBulk, 'timestamp'> | null): any {
if (value == null) {
return value;
}

View File

@@ -41,6 +41,17 @@ export const TypeEnum = {
export type TypeEnum = typeof TypeEnum[keyof typeof TypeEnum];
export function instanceOfTypeEnum(value: any): boolean {
for (const key in TypeEnum) {
if (Object.prototype.hasOwnProperty.call(TypeEnum, key)) {
if (TypeEnum[key as keyof typeof TypeEnum] === value) {
return true;
}
}
}
return false;
}
export function TypeEnumFromJSON(json: any): TypeEnum {
return TypeEnumFromJSONTyped(json, false);
}
@@ -53,3 +64,7 @@ export function TypeEnumToJSON(value?: TypeEnum | null): any {
return value as any;
}
export function TypeEnumToJSONTyped(value: any, ignoreDiscriminator: boolean): TypeEnum {
return value as TypeEnum;
}

View File

@@ -4,8 +4,6 @@ export * from './AccessToken';
export * from './AuthToken';
export * from './AutoMealPlan';
export * from './Automation';
export * from './AutomationTypeEnum';
export * from './BaseUnitEnum';
export * from './BookmarkletImport';
export * from './BookmarkletImportList';
export * from './ConnectorConfigConfig';
@@ -31,16 +29,6 @@ export * from './MealPlan';
export * from './MealType';
export * from './MethodEnum';
export * from './NutritionInformation';
export * from './OpenDataCategory';
export * from './OpenDataConversion';
export * from './OpenDataFood';
export * from './OpenDataFoodProperty';
export * from './OpenDataProperty';
export * from './OpenDataStore';
export * from './OpenDataStoreCategory';
export * from './OpenDataUnit';
export * from './OpenDataUnitTypeEnum';
export * from './OpenDataVersion';
export * from './PaginatedAutomationList';
export * from './PaginatedBookmarkletImportListList';
export * from './PaginatedCookLogList';
@@ -87,13 +75,6 @@ export * from './PatchedInviteLink';
export * from './PatchedKeyword';
export * from './PatchedMealPlan';
export * from './PatchedMealType';
export * from './PatchedOpenDataCategory';
export * from './PatchedOpenDataConversion';
export * from './PatchedOpenDataFood';
export * from './PatchedOpenDataProperty';
export * from './PatchedOpenDataStore';
export * from './PatchedOpenDataUnit';
export * from './PatchedOpenDataVersion';
export * from './PatchedProperty';
export * from './PatchedPropertyType';
export * from './PatchedRecipe';
@@ -140,6 +121,7 @@ export * from './SupermarketCategoryRelation';
export * from './Sync';
export * from './SyncLog';
export * from './ThemeEnum';
export * from './TypeEnum';
export * from './Unit';
export * from './UnitConversion';
export * from './User';

View File

@@ -34,8 +34,11 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
// internal
let currentlyUpdating = ref(false)
let lastAutosync = ref(0)
let autosyncHasFocus = ref(true)
let autoSyncLastTimestamp = ref(new Date('1970-01-01'))
let autoSyncHasFocus = ref(true)
let autoSyncTimeoutId = ref(0)
let undoStack = ref([] as ShoppingOperationHistoryEntry[])
let queueTimeoutId = ref(-1)
let itemCheckSyncQueue = ref([] as IShoppingSyncQueueEntry[])
@@ -168,7 +171,7 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
function refreshFromAPI() {
if (!currentlyUpdating.value) {
currentlyUpdating.value = true
lastAutosync.value = new Date().getTime();
autoSyncLastTimestamp.value = new Date();
let api = new ApiApi()
api.apiShoppingListEntryList().then((r) => {
@@ -199,30 +202,24 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
/**
* perform auto sync request to special endpoint returning only entries changed since last auto sync
* only updates local entries that are older than the server version
*/
function autosync() {
if (!currentlyUpdating.value && autosyncHasFocus.value) {
function autoSync() {
if (!currentlyUpdating.value && autoSyncHasFocus.value && !hasFailedItems()) {
console.log('running autosync')
currentlyUpdating.value = true
let previous_autosync = lastAutosync.value
lastAutosync.value = new Date().getTime();
const api = new ApiApi()
// TODO implement parameters on backend Oepnapi
api.apiShoppingListEntryList({lastAutosync: previous_autosync}).then((r) => {
api.apiShoppingListEntryList({updatedAfter: autoSyncLastTimestamp.value}).then((r) => {
console.log('received auto sync response ', r)
autoSyncLastTimestamp.value = r.timestamp!
r.results.forEach((e) => {
// dont update stale client data
if (!entries.value.has(e.id!) || entries.value.get(e.id!).updatedAt < e.updatedAt) {
console.log('auto sync updating entry ', e)
entries.value.set(e.id!, e)
}
entries.value.set(e.id!, e)
})
currentlyUpdating.value = false
}).catch((err: any) => {
console.warn('auto sync failed')
console.warn('auto sync failed', err)
currentlyUpdating.value = false
})
}
@@ -379,6 +376,11 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
// TODO set timeout for request (previously was 15000ms) or check that default timeout is similar
let p = api.apiShoppingListEntryBulkCreate({shoppingListEntryBulk: entry}, {}).then((r) => {
entry.ids.forEach(id => {
let e = entries.value.get(id)
e.updatedAt = r.timestamp
entries.value.set(id, e)
})
delete itemCheckSyncQueue.value[i]
}).catch((err) => {
if (err.code === "ERR_NETWORK" || err.code === "ECONNABORTED") {
@@ -534,9 +536,14 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
supermarkets,
supermarketCategories,
getEntriesByGroup,
autoSyncTimeoutId,
autoSyncHasFocus,
autoSyncLastTimestamp,
currentlyUpdating,
getFlatEntries,
hasFailedItems,
refreshFromAPI,
autoSync,
createObject,
deleteObject,
updateObject,