Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-andersen committed Sep 15, 2022
1 parent 1c2a9e1 commit 3605570
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
27 changes: 16 additions & 11 deletions dev/src/reference.ts
Expand Up @@ -1619,7 +1619,9 @@ export class Query<T = firestore.DocumentData> implements firestore.Query<T> {
* @param aggregates the aggregations to perform.
* @return an `AggregateQuery` that performs the given aggregations.
*/
aggregate<T extends firestore.AggregateSpec>(aggregates: T): AggregateQuery<T> {
aggregate<T extends firestore.AggregateSpec>(
aggregates: T
): AggregateQuery<T> {
return new AggregateQuery(this, aggregates);
}

Expand Down Expand Up @@ -2308,10 +2310,10 @@ export class Query<T = firestore.DocumentData> implements firestore.Query<T> {
callback(undefined, {document: lastReceivedDocument, readTime});
if (proto.done) {
logger('Query._stream', tag, 'Trigger Logical Termination.');
backendStream.unpipe(stream);
backendStream.resume();
backendStream.end();
stream.end();
backendStream.unpipe(stream);
backendStream.resume();
backendStream.end();
stream.end();
}
} else {
callback(undefined, {readTime});
Expand Down Expand Up @@ -2868,7 +2870,9 @@ export class AggregateField<T> implements firestore.AggregateField<T> {
}
}

export class AggregateQuery<T extends firestore.AggregateSpec> implements firestore.AggregateQuery<T> {
export class AggregateQuery<T extends firestore.AggregateSpec>
implements firestore.AggregateQuery<T> {

private readonly _query: Query<unknown>;
private readonly _aggregates: T;

Expand Down Expand Up @@ -2940,25 +2944,27 @@ export class AggregateQuery<T extends firestore.AggregateSpec> implements firest
data[prop] = serializer.decodeValue(fields[prop]);
}
}
const result = new AggregateQuerySnapshot<T>(this, readTime, data as any); //TODO(tomandersen) remove `as any`
//TODO(tomandersen) remove `as any`
const result = new AggregateQuerySnapshot<T>(this, readTime, data as any);
callback(undefined, result);
} else {
callback(Error('unexpected'));
}
},
})
});

firestore
.initializeIfNeeded(tag)
.then(async () => {
const request = this.toProto(transactionId);
const backendStream = await firestore.requestStream(
'runAggregationQuery',
/* bidirectional= */ false,
/* bidirectional= */ false,
request,
tag
);
stream.on('close', () => {
backendStream.resume()
backendStream.resume();
backendStream.end();
})
backendStream.on('error', err => {
Expand Down Expand Up @@ -3009,7 +3015,6 @@ export class AggregateQuery<T extends firestore.AggregateSpec> implements firest
}

isEqual(other: firestore.AggregateQuery<T>): boolean {
new AggregateQuery(null as any, {2: AggregateField.count()})
if (this === other) {
return true;
}
Expand Down
1 change: 0 additions & 1 deletion dev/system-test/firestore.ts
Expand Up @@ -17,7 +17,6 @@ import {
DocumentData,
WithFieldValue,
PartialWithFieldValue,
AggregateQuery,
SetOptions,
Settings,
} from '@google-cloud/firestore';
Expand Down
4 changes: 2 additions & 2 deletions dev/test/aggregateQuery.ts
Expand Up @@ -25,7 +25,7 @@ import {expect, use} from 'chai';
import {google} from '../protos/firestore_v1_proto_api';
import api = google.firestore.v1;
import * as chaiAsPromised from 'chai-as-promised';
import {setTimeoutHandler} from "../src/backoff";
import {setTimeoutHandler} from '../src/backoff';
use(chaiAsPromised);

describe('aggregate query interface', () => {
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('aggregate query interface', () => {
readTime: {seconds: 5, nanos: 6},
};
const overrides: ApiOverride = {
runAggregationQuery: request => streamWithoutEnd(result),
runAggregationQuery: () => streamWithoutEnd(result),
};

firestore = await createInstance(overrides);
Expand Down
2 changes: 1 addition & 1 deletion dev/test/count.ts
Expand Up @@ -15,7 +15,7 @@
import {expect} from 'chai';

import {Firestore} from '../src';
import {AggregateField} from "../src/reference";
import {AggregateField} from '../src/reference';

export async function Demo0_NormalQuery(db: Firestore) {
const query = db.collection('games/halo/players');
Expand Down
14 changes: 7 additions & 7 deletions dev/test/query.ts
Expand Up @@ -410,15 +410,15 @@ describe('query interface', () => {
const queryB = firestore.collection('collectionId');

const queryEquals = (equals: Query[], notEquals: Query[]) => {
for (const equal1 of equals) {
for (const equal2 of equals) {
expect(equal1.isEqual(equal2)).to.be.true;
expect(equal2.isEqual(equal1)).to.be.true;
for (let i = 0; i < equals.length; ++i) {
for (const equal of equals) {
expect(equals[i].isEqual(equal)).to.be.true;
expect(equal.isEqual(equals[i])).to.be.true;
}

for (const notEqual of notEquals) {
expect(equal1.isEqual(notEqual)).to.be.false;
expect(notEqual.isEqual(equal1)).to.be.false;
expect(equals[i].isEqual(notEqual)).to.be.false;
expect(notEqual.isEqual(equals[i])).to.be.false;
}
}
};
Expand Down Expand Up @@ -630,7 +630,7 @@ describe('query interface', () => {
});

// Test Logical Termination on get()
it('successful return without ending the stream on get()', async () => {
it('successful return without ending the stream on get()', () => {
const overrides: ApiOverride = {
runQuery: request => {
queryEquals(request);
Expand Down

0 comments on commit 3605570

Please sign in to comment.