Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/dep…
Browse files Browse the repository at this point in the history
…loyment-frontend

# Conflicts:
#	package-lock.json
  • Loading branch information
timonmasberg committed Dec 29, 2024
2 parents b007f03 + 64926b2 commit 1b1163f
Show file tree
Hide file tree
Showing 7 changed files with 7,328 additions and 5,659 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,35 @@ export class ImplProtocolEntryRepository implements ProtocolEntryRepository {
direction: 'preceding' | 'subsequent',
startingFrom?: Date,
): Promise<ProtocolEntryBase[]> {
const query = this.getQueryForSubset(
const protocolEntries = await this.getQueryForSubset(
organizationId,
direction === 'preceding' ? 'asc' : 'desc',
startingFrom,
).limit(count);

const protocolEntries = await query.lean().exec();
)
.limit(count)
.lean<ProtocolEntryBaseDocument[]>()
.exec();

if (direction === 'preceding') {
protocolEntries.reverse();
}

return protocolEntries.map((entry) =>
this.mapper.map(entry as ProtocolEntryBaseDocument),
return protocolEntries.map((entry) => this.mapper.map(entry));
}

async hasProtocolEntries(
organizationId: string,
direction: 'preceding' | 'subsequent',
startingFrom?: Date,
): Promise<boolean> {
const query = this.getQueryForSubset(
organizationId,
direction === 'preceding' ? 'asc' : 'desc',
startingFrom,
);
const protocolEntry = await query.select('_id').findOne();

return protocolEntry !== null;
}

private getQueryForSubset(
Expand All @@ -68,19 +82,4 @@ export class ImplProtocolEntryRepository implements ProtocolEntryRepository {
}
return query;
}

async hasProtocolEntries(
organizationId: string,
direction: 'preceding' | 'subsequent',
startingFrom?: Date,
): Promise<boolean> {
const query = this.getQueryForSubset(
organizationId,
direction === 'preceding' ? 'asc' : 'desc',
startingFrom,
);
const protocolEntry = await query.select('_id').findOne();

return protocolEntry !== null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ producerPath.discriminator(ProducerType.USER_PRODUCER, UserProducerSchema);
producerPath.discriminator(ProducerType.SYSTEM_PRODUCER, SystemProducerSchema);

ProtocolEntryBaseSchema.index({ orgId: 1, time: 1 }, { unique: false });
ProtocolEntryBaseSchema.index({ orgId: 1 }, { unique: false });

@Schema()
export class ProtocolMessageEntryBaseDocument extends ProtocolEntryBaseDocument {
Expand Down
8 changes: 3 additions & 5 deletions libs/api/tetra/src/lib/infra/schema/tetra-config.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { AutoMap } from '@automapper/classes';
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

@Schema({ collection: 'tetra-configs' })
export class TetraConfigDocument extends Document {
@Prop({ unique: true })
@AutoMap()
orgId: string;
import { BaseDocument } from '@kordis/api/shared';

@Schema({ collection: 'tetra-configs' })
export class TetraConfigDocument extends BaseDocument {
@Prop()
@AutoMap()
tetraControlApiUrl: string;
Expand Down
7 changes: 1 addition & 6 deletions libs/spa/core/graphql/src/lib/graphql.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ describe('GraphqlService', () => {
it('should call apollo.mutate and return the response', async () => {
const mutation = {} as DocumentNode;
const variables = {};
const optimisticResponse = { foo: 'bar' };
const response: MutationResult = {
loading: false,
data: { foo: 'bar' },
Expand All @@ -82,16 +81,12 @@ describe('GraphqlService', () => {
apolloMock.mutate.mockReturnValue(of(response));

const result = await firstValueFrom(
graphqlService.mutate$(mutation, variables, optimisticResponse),
graphqlService.mutate$(mutation, variables),
);

expect(apolloMock.mutate).toHaveBeenCalledWith({
mutation,
variables,
optimisticResponse: {
__typename: 'Mutation',
...optimisticResponse,
},
});
expect(result).toEqual({
foo: 'bar',
Expand Down
6 changes: 1 addition & 5 deletions libs/spa/core/graphql/src/lib/graphql.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { DocumentNode } from '@apollo/client/core';
import { DocumentNode, Unmasked } from '@apollo/client/core';
import { Apollo } from 'apollo-angular';
import { Observable, map } from 'rxjs';

Expand Down Expand Up @@ -43,15 +43,11 @@ export class GraphqlService {
mutate$<TData = unknown>(
mutation: DocumentNode,
variables?: Record<string, unknown>,
optimisticResponse?: TData,
): Observable<TData> {
return this.apollo
.mutate<TData>({
mutation,
variables,
optimisticResponse: optimisticResponse
? { __typename: 'Mutation', ...optimisticResponse }
: undefined,
})
.pipe(map(({ data }) => data as TData));
}
Expand Down
Loading

0 comments on commit 1b1163f

Please sign in to comment.