IMP-328: Bump deanonimus. Reverting table optimizations (#393)

This commit is contained in:
Rinat Arsaev 2024-09-30 17:18:09 +09:00 committed by GitHub
parent 0f2441a130
commit f84c58c442
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 45 additions and 59 deletions

8
package-lock.json generated
View File

@ -20,7 +20,7 @@
"@angular/platform-server": "18.2.4", "@angular/platform-server": "18.2.4",
"@angular/router": "18.2.4", "@angular/router": "18.2.4",
"@ngneat/input-mask": "6.0.0", "@ngneat/input-mask": "6.0.0",
"@vality/deanonimus-proto": "2.0.1-2a02d87.0", "@vality/deanonimus-proto": "2.0.1-6605c72.0",
"@vality/domain-proto": "2.0.1-7762f6c.0", "@vality/domain-proto": "2.0.1-7762f6c.0",
"@vality/dominator-proto": "1.0.1-41bee97.0", "@vality/dominator-proto": "1.0.1-41bee97.0",
"@vality/fistful-proto": "2.0.1-88e69a5.0", "@vality/fistful-proto": "2.0.1-88e69a5.0",
@ -5920,9 +5920,9 @@
} }
}, },
"node_modules/@vality/deanonimus-proto": { "node_modules/@vality/deanonimus-proto": {
"version": "2.0.1-2a02d87.0", "version": "2.0.1-6605c72.0",
"resolved": "https://registry.npmjs.org/@vality/deanonimus-proto/-/deanonimus-proto-2.0.1-2a02d87.0.tgz", "resolved": "https://registry.npmjs.org/@vality/deanonimus-proto/-/deanonimus-proto-2.0.1-6605c72.0.tgz",
"integrity": "sha512-mokuK6w+ExASdDE6+L9bM2SaS0yVPSyBvXavY8rRtNzZgVdmj7KSRiyGmXz41grhS6jcvD8aR85Nj4o7/iogmQ==" "integrity": "sha512-vRJV1F+KChEGXRvpA5VBgT4y6pUpIyBOFyKfk74AyRG6VyERGt7Qh5rnUD/odaSOzJrI91qXfb4vIh8qt970ng=="
}, },
"node_modules/@vality/domain-proto": { "node_modules/@vality/domain-proto": {
"version": "2.0.1-7762f6c.0", "version": "2.0.1-7762f6c.0",

View File

@ -29,7 +29,7 @@
"@angular/platform-server": "18.2.4", "@angular/platform-server": "18.2.4",
"@angular/router": "18.2.4", "@angular/router": "18.2.4",
"@ngneat/input-mask": "6.0.0", "@ngneat/input-mask": "6.0.0",
"@vality/deanonimus-proto": "2.0.1-2a02d87.0", "@vality/deanonimus-proto": "2.0.1-6605c72.0",
"@vality/domain-proto": "2.0.1-7762f6c.0", "@vality/domain-proto": "2.0.1-7762f6c.0",
"@vality/dominator-proto": "1.0.1-41bee97.0", "@vality/dominator-proto": "1.0.1-41bee97.0",
"@vality/fistful-proto": "2.0.1-88e69a5.0", "@vality/fistful-proto": "2.0.1-88e69a5.0",

View File

@ -1,23 +1,27 @@
import { Injectable, DestroyRef } from '@angular/core'; import { Injectable, DestroyRef } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Domain, DomainObject, Reference } from '@vality/domain-proto/domain'; import { DomainObject, Reference } from '@vality/domain-proto/domain';
import { Commit, Snapshot, Version } from '@vality/domain-proto/domain_config'; import { Commit, Snapshot, Version } from '@vality/domain-proto/domain_config';
import { NotifyLogService, handleError, inProgressFrom, progressTo } from '@vality/ng-core'; import { NotifyLogService, handleError, inProgressFrom, progressTo } from '@vality/ng-core';
import { getUnionKey } from '@vality/ng-thrift'; import { getUnionKey } from '@vality/ng-thrift';
import isEqual from 'lodash-es/isEqual';
import { BehaviorSubject, defer, Observable, of, ReplaySubject, filter, combineLatest } from 'rxjs'; import { BehaviorSubject, defer, Observable, of, ReplaySubject, filter, combineLatest } from 'rxjs';
import { map, shareReplay, startWith, switchMap, take, tap } from 'rxjs/operators'; import { map, shareReplay, startWith, switchMap, take, tap } from 'rxjs/operators';
import { DomainSecretService } from '../../../shared/services'; import { DomainSecretService } from '../../../shared/services';
import { RepositoryService } from '../repository.service'; import { RepositoryService } from '../repository.service';
import { createObjectHash } from '../utils/create-object-hash';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class DomainStoreService { export class DomainStoreService {
version$ = combineLatest([defer(() => this.snapshot$), defer(() => this.progress$)]).pipe( domain$ = defer(() => this.rawDomain$).pipe(
filter(([, p]) => !p), map((d) => this.domainSecretService.reduceDomain(d)),
shareReplay({ refCount: true, bufferSize: 1 }),
);
version$ = defer(() => this.loadedSnapshot$).pipe(
map(([s]) => s.version), map(([s]) => s.version),
shareReplay({ refCount: true, bufferSize: 1 }),
); );
isLoading$ = inProgressFrom( isLoading$ = inProgressFrom(
() => this.progress$, () => this.progress$,
@ -34,8 +38,31 @@ export class DomainStoreService {
takeUntilDestroyed(this.destroyRef), takeUntilDestroyed(this.destroyRef),
shareReplay(1), shareReplay(1),
); );
private loadedSnapshot$ = combineLatest([
defer(() => this.snapshot$),
defer(() => this.progress$),
]).pipe(
filter(([, p]) => !p),
shareReplay({ refCount: true, bufferSize: 1 }),
);
private reload$ = new ReplaySubject<void>(1); private reload$ = new ReplaySubject<void>(1);
private progress$ = new BehaviorSubject(0); private progress$ = new BehaviorSubject(0);
private rawDomain$ = this.loadedSnapshot$.pipe(
map(([s]) => s?.domain),
shareReplay({ refCount: true, bufferSize: 1 }),
);
private objects$ = combineLatest([this.rawDomain$, this.domain$]).pipe(
map(
([rawDomain, domain]) =>
new Map(
Array.from(rawDomain).map(([ref, raw]) => [
createObjectHash(ref),
{ raw, reduced: domain.get(ref) },
]),
),
),
shareReplay({ refCount: true, bufferSize: 1 }),
);
constructor( constructor(
private repositoryService: RepositoryService, private repositoryService: RepositoryService,
@ -48,17 +75,9 @@ export class DomainStoreService {
this.reload$.next(); this.reload$.next();
} }
getDomain(raw = false): Observable<Domain> {
return combineLatest([defer(() => this.snapshot$), defer(() => this.progress$)]).pipe(
filter(([, p]) => !p),
map(([s]) => s?.domain),
map((d) => (raw ? d : this.domainSecretService.reduceDomain(d))),
);
}
getObject(ref: Reference, raw = false): Observable<DomainObject> { getObject(ref: Reference, raw = false): Observable<DomainObject> {
return this.getDomain(raw).pipe( return this.objects$.pipe(
map((domain) => Array.from(domain).find(([r]) => isEqual(ref, r))?.[1]), map((objects) => objects.get(createObjectHash(ref))?.[raw ? 'raw' : 'reduced']),
); );
} }
@ -69,7 +88,7 @@ export class DomainStoreService {
getObjectsRefs<T extends keyof DomainObject>( getObjectsRefs<T extends keyof DomainObject>(
objectType: T, objectType: T,
): Observable<[Reference, DomainObject][]> { ): Observable<[Reference, DomainObject][]> {
return this.getDomain().pipe( return this.domain$.pipe(
map((d) => Array.from(d).filter(([, o]) => getUnionKey(o) === objectType)), map((d) => Array.from(d).filter(([, o]) => getUnionKey(o) === objectType)),
); );
} }

View File

@ -92,8 +92,7 @@
Change status Change status
</button> </button>
<button mat-raised-button (click)="createWallet()">Add wallet modification</button> <button mat-raised-button (click)="createWallet()">Add wallet modification</button>
<!-- <button mat-raised-button (click)="createShop(false)">Add shop modifications</button>--> <button mat-raised-button (click)="createShop()">Add shop modifications</button>
<button mat-raised-button (click)="createShop(true)">Add shop modifications</button>
<button color="primary" mat-raised-button (click)="addModification()"> <button color="primary" mat-raised-button (click)="addModification()">
Add modification Add modification
</button> </button>

View File

@ -115,13 +115,13 @@ export class ClaimComponent {
}); });
} }
createShop(withoutPayout = true) { createShop() {
combineLatest([this.party$, this.claim$]) combineLatest([this.party$, this.claim$])
.pipe( .pipe(
first(), first(),
switchMap(([party, claim]) => switchMap(([party, claim]) =>
this.dialogService this.dialogService
.open(CreateShopDialogComponent, { party, claim, withoutPayout }) .open(CreateShopDialogComponent, { party, claim })
.afterClosed(), .afterClosed(),
), ),
takeUntilDestroyed(this.destroyRef), takeUntilDestroyed(this.destroyRef),

View File

@ -74,10 +74,7 @@ const DEFAULT_SHOP_LOCATION: ShopLocation = {
styles: ``, styles: ``,
}) })
export class CreateShopDialogComponent export class CreateShopDialogComponent
extends DialogSuperclass< extends DialogSuperclass<CreateShopDialogComponent, { party: Party; claim: Claim }>
CreateShopDialogComponent,
{ party: Party; claim: Claim; withoutPayout: boolean }
>
implements OnInit implements OnInit
{ {
static defaultDialogConfig = DEFAULT_DIALOG_CONFIG.large; static defaultDialogConfig = DEFAULT_DIALOG_CONFIG.large;
@ -156,7 +153,6 @@ export class CreateShopDialogComponent
this.form.value; this.form.value;
const contractorId = short().uuid(); const contractorId = short().uuid();
const contractId = short().uuid(); const contractId = short().uuid();
const payoutToolId = short().generate();
const shopId = short().uuid(); const shopId = short().uuid();
this.claimManagementService this.claimManagementService
.UpdateClaim( .UpdateClaim(
@ -188,31 +184,6 @@ export class CreateShopDialogComponent
}, },
}, },
}, },
...(this.dialogData.withoutPayout
? []
: [
{
party_modification: {
contract_modification: {
id: contractId,
modification: {
payout_tool_modification: {
payout_tool_id: payoutToolId,
modification: {
creation: {
currency: currency,
tool_info: {
russian_bank_account:
DEFAULT_RUSSIAN_BANK_ACCOUNT,
},
},
},
},
},
},
},
},
]),
{ {
party_modification: { party_modification: {
shop_modification: { shop_modification: {
@ -223,9 +194,6 @@ export class CreateShopDialogComponent
category: category, category: category,
location: DEFAULT_SHOP_LOCATION, location: DEFAULT_SHOP_LOCATION,
contract_id: contractId, contract_id: contractId,
...(this.dialogData.withoutPayout
? {}
: { payout_tool_id: payoutToolId }),
}, },
}, },
}, },

View File

@ -59,7 +59,7 @@ export class DomainObjectsTableComponent implements OnInit {
(this.qp.params.types as (keyof DomainObject)[]) || [], (this.qp.params.types as (keyof DomainObject)[]) || [],
); );
objects$: Observable<DomainObjectData[]> = combineLatest([ objects$: Observable<DomainObjectData[]> = combineLatest([
this.domainStoreService.getDomain(), this.domainStoreService.domain$,
this.typesControl.valueChanges.pipe(startWith(this.typesControl.value)), this.typesControl.valueChanges.pipe(startWith(this.typesControl.value)),
]).pipe( ]).pipe(
switchMap(([objects, types]) => switchMap(([objects, types]) =>

View File

@ -34,7 +34,7 @@ export class DomainObjectCardComponent implements OnChanges {
ref$ = new ReplaySubject<Reference>(1); ref$ = new ReplaySubject<Reference>(1);
progress$ = this.domainStoreService.isLoading$; progress$ = this.domainStoreService.isLoading$;
domainObject$ = combineLatest([this.domainStoreService.getDomain(), this.ref$]).pipe( domainObject$ = combineLatest([this.domainStoreService.domain$, this.ref$]).pipe(
map(([domain, ref]) => map(([domain, ref]) =>
domain.get(Array.from(domain.keys()).find((k) => isEqualThrift(k, ref))), domain.get(Array.from(domain.keys()).find((k) => isEqualThrift(k, ref))),
), ),