disable caching for reverse relations

This commit is contained in:
FinnStutzenstein 2020-01-21 09:48:26 +01:00
parent e67ca77ad1
commit 7ab5346198
9 changed files with 28 additions and 18 deletions

View File

@ -98,6 +98,17 @@ export class RelationManagerService {
viewModel: BaseViewModel, viewModel: BaseViewModel,
relation: RelationDefinition relation: RelationDefinition
): any { ): any {
// No cache for reverse relations.
// The issue: we cannot invalidate the cache, if a new object is created (The
// following example is for a O2M foreign relation):
// There is no possibility to detect the create case: The target does not update,
// all related models does not update. The autoupdate does not provide the created-
// information. So we may check, if the relaten has changed in length every time. But
// this is the same as just resolving the relation every time it is requested. So no cache here.
if (isReverseRelationDefinition(relation)) {
return this.handleRelation(model, viewModel, relation) as BaseViewModel | BaseViewModel[];
}
let result: any; let result: any;
const cacheProperty = '__' + property; const cacheProperty = '__' + property;

View File

@ -78,6 +78,9 @@ export class SearchValueSelectorComponent extends BaseFormControlComponent<Selec
if (!value) { if (!value) {
return; return;
} }
if (Array.isArray(value)) {
this.selectableItems = value;
} else {
this.subscriptions.push( this.subscriptions.push(
value.pipe(auditTime(10)).subscribe(items => { value.pipe(auditTime(10)).subscribe(items => {
this.selectableItems = items; this.selectableItems = items;
@ -87,6 +90,7 @@ export class SearchValueSelectorComponent extends BaseFormControlComponent<Selec
}) })
); );
} }
}
public searchValue: FormControl; public searchValue: FormControl;

View File

@ -27,11 +27,6 @@ type OptionsObject = { user_id: number; user: ViewUser }[];
styleUrls: ['./assignment-poll-dialog.component.scss'] styleUrls: ['./assignment-poll-dialog.component.scss']
}) })
export class AssignmentPollDialogComponent extends BasePollDialogComponent implements OnInit { export class AssignmentPollDialogComponent extends BasePollDialogComponent implements OnInit {
/**
* The actual poll data to work on
*/
public poll: AssignmentPoll;
/** /**
* The summary values that will have fields in the dialog * The summary values that will have fields in the dialog
*/ */

View File

@ -6,7 +6,7 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("core", "0025_projector_color"), ("core", "0026_remove_history_restricted"),
] ]
operations = [ operations = [

View File

@ -37,7 +37,7 @@ def calculate_aspect_ratios(apps, schema_editor):
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("core", "0026_projector_size_1"), ("core", "0027_projector_size_1"),
] ]
operations = [ operations = [

View File

@ -6,7 +6,7 @@ from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("core", "0027_projector_size_2"), ("core", "0028_projector_size_2"),
] ]
operations = [ operations = [

View File

@ -8,6 +8,7 @@ from jsonfield import JSONField
from openslides.utils.autoupdate import AutoupdateElement from openslides.utils.autoupdate import AutoupdateElement
from openslides.utils.cache import element_cache, get_element_id from openslides.utils.cache import element_cache, get_element_id
from openslides.utils.locking import locking
from openslides.utils.manager import BaseManager from openslides.utils.manager import BaseManager
from openslides.utils.models import SET_NULL_AND_AUTOUPDATE, RESTModelMixin from openslides.utils.models import SET_NULL_AND_AUTOUPDATE, RESTModelMixin

View File

@ -9,7 +9,6 @@ from mypy_extensions import TypedDict
from ..utils.websocket import WEBSOCKET_CHANGE_ID_TOO_HIGH from ..utils.websocket import WEBSOCKET_CHANGE_ID_TOO_HIGH
from . import logging from . import logging
from .auth import UserDoesNotExist, async_anonymous_is_enabled from .auth import UserDoesNotExist, async_anonymous_is_enabled
from .autoupdate import AutoupdateFormat
from .cache import ChangeIdTooLowError, element_cache, split_element_id from .cache import ChangeIdTooLowError, element_cache, split_element_id
from .utils import get_worker_id from .utils import get_worker_id
from .websocket import ProtocollAsyncJsonWebsocketConsumer from .websocket import ProtocollAsyncJsonWebsocketConsumer