Conversation
🦋 Changeset detectedLatest commit: 84ae093 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello @milaGGL, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request expands the array processing capabilities within the Firestore SDK by adding eight new expressions. These functions provide developers with enhanced tools to extract specific elements (first, last, or a specified number of elements) and calculate statistical values (minimum, maximum, or a specified number of min/max elements) directly from arrays within their data pipelines, streamlining array-based data transformations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces eight new array expression functions to Firestore pipelines, enhancing the query capabilities for array fields. The new functions are arrayFirst, arrayFirstN, arrayLast, arrayLastN, arrayMaximum, arrayMaximumN, arrayMinimum, and arrayMinimumN. The changes are well-implemented and include corresponding API definitions, documentation, and comprehensive tests. I have identified a few areas for improvement, primarily concerning API documentation consistency and formatting in the generated documentation files.
There was a problem hiding this comment.
Code Review
This PR introduces a comprehensive set of new array expressions for Firestore pipelines, including functions for filtering, slicing, and finding elements within arrays. The implementation is well-tested with extensive integration tests. My feedback is primarily focused on improving the accuracy and consistency of the documentation for these new features to ensure clarity for developers. I've pointed out a few places where examples are missing or descriptions of return values could be more precise based on the test cases.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive set of new array expressions to Firestore pipelines, which is a great feature enhancement. The implementation and tests are thorough. My feedback is mainly focused on improving code organization, documentation clarity, and minor code simplification for better maintainability. I've pointed out some redundant function calls, suggested reordering of exports and methods for consistency, and highlighted some areas in the documentation that could be confusing for users due to duplicated entries and incorrect links.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive set of new array expressions for Firestore pipelines, which is a great addition. The implementation is mostly straightforward, with new methods on the Expression class and corresponding top-level functions. The test coverage for these new features appears to be thorough.
I have two main points of feedback. First, the generated documentation for the new overloaded functions contains a lot of duplication, which impacts readability. Second, the behavior of the arraySlice function's end parameter is inclusive, which is inconsistent with the standard slice behavior in many languages and could be a source of confusion for developers.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a suite of new array expressions for Firestore pipelines, enhancing query capabilities. The implementation looks solid, and the accompanying tests are comprehensive.
I've identified a couple of areas for improvement:
- In
packages/firestore/src/lite-api/expressions.ts, there are some magic strings ('first','last') that should be extracted into constants for better readability and maintainability. - The auto-generated documentation in
docs-devsite/has duplicate headers for overloaded functions. This should be addressed to improve documentation quality and avoid potential issues with HTML rendering and navigation.
Overall, this is a great feature addition. Addressing these minor points will make the code and documentation even better.
| ## Expression.arrayFirstN() | ||
|
|
||
| > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. | ||
| > | ||
|
|
||
| Returns the first `n` elements of the array. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| arrayFirstN(n: number): FunctionExpression; | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | n | number | The number of elements to return. | | ||
|
|
||
| <b>Returns:</b> | ||
|
|
||
| [FunctionExpression](./firestore_lite_pipelines.functionexpression.md#functionexpression_class) | ||
|
|
||
| A new `Expression` representing the first `n` elements. | ||
|
|
||
| ### Example | ||
|
|
||
|
|
||
| ```typescript | ||
| // Get the first 3 elements of the 'myArray' field. | ||
| field("myArray").arrayFirstN(3); | ||
|
|
||
| ``` | ||
|
|
||
| ## Expression.arrayFirstN() | ||
|
|
||
| > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. | ||
| > | ||
|
|
||
| Returns the first `n` elements of the array. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| arrayFirstN(n: Expression): FunctionExpression; | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | n | [Expression](./firestore_lite_pipelines.expression.md#expression_class) | An expression evaluating to the number of elements to return. | | ||
|
|
||
| <b>Returns:</b> | ||
|
|
||
| [FunctionExpression](./firestore_lite_pipelines.functionexpression.md#functionexpression_class) | ||
|
|
||
| A new `Expression` representing the first `n` elements. | ||
|
|
||
| ### Example | ||
|
|
||
|
|
||
| ```typescript | ||
| // Get the first n elements of the 'myArray' field. | ||
| field("myArray").arrayFirstN(field("count")); | ||
|
|
||
| ``` |
There was a problem hiding this comment.
The documentation for overloaded methods like arrayFirstN is generating duplicate markdown headers. This can lead to issues with page navigation, broken links, and creates invalid HTML. It's better to document all overloads under a single, unique header.
For example, you could structure it like this:
## Expression.arrayFirstN()
... description ...
**Signature 1:**
```typescript
arrayFirstN(n: number): FunctionExpression;... params, returns, example for signature 1 ...
Signature 2:
arrayFirstN(n: Expression): FunctionExpression;... params, returns, example for signature 2 ...
This same issue applies to `arrayIndexOf`, `arrayIndexOfAll`, `arrayLastIndexOf`, `arrayMaximumN`, and `arrayMinimumN` in this file.
| ## Expression.arrayFirstN() | ||
|
|
||
| > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. | ||
| > | ||
|
|
||
| Returns the first `n` elements of the array. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| arrayFirstN(n: number): FunctionExpression; | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | n | number | The number of elements to return. | | ||
|
|
||
| <b>Returns:</b> | ||
|
|
||
| [FunctionExpression](./firestore_pipelines.functionexpression.md#functionexpression_class) | ||
|
|
||
| A new `Expression` representing the first `n` elements. | ||
|
|
||
| ### Example | ||
|
|
||
|
|
||
| ```typescript | ||
| // Get the first 3 elements of the 'myArray' field. | ||
| field("myArray").arrayFirstN(3); | ||
|
|
||
| ``` | ||
|
|
||
| ## Expression.arrayFirstN() | ||
|
|
||
| > This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. | ||
| > | ||
|
|
||
| Returns the first `n` elements of the array. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| arrayFirstN(n: Expression): FunctionExpression; | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | n | [Expression](./firestore_pipelines.expression.md#expression_class) | An expression evaluating to the number of elements to return. | | ||
|
|
||
| <b>Returns:</b> | ||
|
|
||
| [FunctionExpression](./firestore_pipelines.functionexpression.md#functionexpression_class) | ||
|
|
||
| A new `Expression` representing the first `n` elements. | ||
|
|
||
| ### Example | ||
|
|
||
|
|
||
| ```typescript | ||
| // Get the first n elements of the 'myArray' field. | ||
| field("myArray").arrayFirstN(field("count")); | ||
|
|
||
| ``` |
There was a problem hiding this comment.
The documentation for overloaded methods like arrayFirstN is generating duplicate markdown headers. This can lead to issues with page navigation, broken links, and creates invalid HTML. It's better to document all overloads under a single, unique header.
For example, you could structure it like this:
## Expression.arrayFirstN()
... description ...
**Signature 1:**
```typescript
arrayFirstN(n: number): FunctionExpression;... params, returns, example for signature 1 ...
Signature 2:
arrayFirstN(n: Expression): FunctionExpression;... params, returns, example for signature 2 ...
This same issue applies to `arrayIndexOf`, `arrayIndexOfAll`, `arrayLastIndexOf`, `arrayMaximumN`, and `arrayMinimumN` in this file.
| arrayIndexOf(search: unknown | Expression): FunctionExpression { | ||
| return new FunctionExpression( | ||
| 'array_index_of', | ||
| [this, valueToDefaultExpr(search), valueToDefaultExpr('first')], |
There was a problem hiding this comment.
The string literal 'first' is a magic string. It would be better to define it as a constant to improve readability and maintainability. The same applies to 'last' on line 1566.
Consider creating a small set of constants for these values, for example:
const ARRAY_INDEX_OF_FIRST = 'first';
const ARRAY_INDEX_OF_LAST = 'last';This would make the code easier to understand and less prone to typos.
Add new array expressions
arrayFirst,arrayFirstN,arrayLast,arrayLastN,arrayMinimum,arrayMinimumN,arrayMaximum,arrayMaximumN,arrayIndexOf,arrayLastIndexOf,arrayIndexOfAll.