-
Notifications
You must be signed in to change notification settings - Fork 188
Add time between queries #1182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add time between queries #1182
Conversation
WalkthroughThe patch changes example.php’s getSSLPage active platform from "console" to "server", switching the fetched spec to swagger2-{version}-server.json. It adds inclusive range query helpers createdBetween and updatedBetween to Query implementations across multiple SDK templates (Android/Kotlin, Dart, Deno, .NET, Go, PHP, Python, React Native, Ruby, Swift, Web). Corresponding tests and sample test invocations were added across language-specific test files. templates/web/src/query.ts.twig contains a duplicate createdBetween insertion. No other logic or error handling was altered. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (19)
example.php (1)
41-44
: Remove redundant commented server line
Spec URL is reachable (HTTP 200).- // $platform = 'client'; - $platform = 'server'; - // $platform = 'server'; + // $platform = 'client'; + $platform = 'server';tests/languages/php/test.php (1)
160-166
: Parameter order and helper availability verified
The Query class defines createdBetween(string $start, string $end) and updatedBetween(string $start, string $end), so the (start, end) order is correct.Consider adding an equal-bounds sample to document inclusivity:
echo Query::createdAfter('2023-01-01') . "\n"; echo Query::createdBetween('2023-01-01', '2023-12-31') . "\n"; +echo Query::createdBetween('2023-01-01', '2023-01-01') . "\n";
templates/deno/test/query.test.ts.twig (1)
236-239
: Add boundary/invalid-order cases for robustness.
Consider tests for equal dates and start > end to lock intended behavior (either allow or reject).+ test('createdBetween equal dates', () => assertEquals( + Query.createdBetween('2023-01-01', '2023-01-01').toString(), + `{"method":"createdBetween","values":["2023-01-01","2023-01-01"]}`, + )); + // If start > end should be allowed, keep this; otherwise expect a thrown error once implemented. + test('updatedBetween reversed range', () => assertEquals( + Query.updatedBetween('2023-12-31', '2023-01-01').toString(), + `{"method":"updatedBetween","values":["2023-12-31","2023-01-01"]}`, + ));templates/swift/Sources/Query.swift.twig (1)
378-384
: Document inclusivity and consider Date overloads.
Minor polish: clarify inclusive semantics and optionally add Date-based overloads formatting to ISO 8601.- public static func updatedBetween(_ start: String, _ end: String) -> String { + /// Inclusive range between two ISO 8601 dates (e.g., "YYYY-MM-DD"). + public static func updatedBetween(_ start: String, _ end: String) -> String { return Query( method: "updatedBetween", values: [start, end] ).description }Additional (outside this hunk):
// Optional convenience overloads public static func createdBetween(_ start: Date, _ end: Date) -> String { let f = ISO8601DateFormatter() f.formatOptions = [.withFullDate] return createdBetween(f.string(from: start), f.string(from: end)) } public static func updatedBetween(_ start: Date, _ end: Date) -> String { let f = ISO8601DateFormatter() f.formatOptions = [.withFullDate] return updatedBetween(f.string(from: start), f.string(from: end)) }tests/languages/apple/Tests.swift (1)
198-198
: Prefer an assertion over print to detect regressions.
E.g., assert the emitted JSON contains the method name.- print(Query.updatedBetween("2023-01-01", "2023-12-31")) + let ub = Query.updatedBetween("2023-01-01", "2023-12-31") + XCTAssertTrue(ub.contains(#""method":"updatedBetween""#))tests/languages/swift/Tests.swift (1)
188-188
: Add a minimal assertion instead of print.
Helps catch string format regressions.- print(Query.updatedBetween("2023-01-01", "2023-12-31")) + let ub = Query.updatedBetween("2023-01-01", "2023-12-31") + XCTAssertTrue(ub.contains(#""method":"updatedBetween""#))tests/languages/flutter/tests.dart (2)
195-195
: Prefer assertions over prints for new helpers.Consider decoding JSON and asserting method/values to catch regressions instead of just printing.
198-198
: Same here: add a simple assertion for updatedBetween.Decode and assert method === "updatedBetween" and values length === 2.
templates/react-native/src/query.ts.twig (2)
173-182
: Clarify inclusivity and date format in JSDoc for createdBetween.Document that the range is inclusive and expects ISO‑8601 strings to avoid ambiguity across SDKs.
- /** - * Filter resources where document was created between dates. - * - * @param {string} start - * @param {string} end - * @returns {string} - */ + /** + * Filter resources where document was created between dates (inclusive). + * + * @param {string} start ISO-8601 date/time string (e.g., '2023-01-01' or '2023-01-01T00:00:00Z') + * @param {string} end ISO-8601 date/time string + * @returns {string} + */
201-210
: Mirror the inclusivity/date-format note for updatedBetween.Keep docs consistent with createdBetween.
- /** - * Filter resources where document was updated between dates. - * - * @param {string} start - * @param {string} end - * @returns {string} - */ + /** + * Filter resources where document was updated between dates (inclusive). + * + * @param {string} start ISO-8601 date/time string (e.g., '2023-01-01' or '2023-01-01T00:00:00Z') + * @param {string} end ISO-8601 date/time string + * @returns {string} + */tests/languages/android/Tests.kt (1)
221-224
: LGTM; consider a boundary case where start == end.Adds confidence that “between” is inclusive.
writeToFile(Query.createdAfter("2023-01-01")) writeToFile(Query.createdBetween("2023-01-01", "2023-12-31")) + writeToFile(Query.createdBetween("2023-05-01", "2023-05-01")) writeToFile(Query.updatedBefore("2023-01-01")) writeToFile(Query.updatedAfter("2023-01-01")) writeToFile(Query.updatedBetween("2023-01-01", "2023-12-31")) + writeToFile(Query.updatedBetween("2023-05-01", "2023-05-01"))tests/languages/dotnet/Tests.cs (1)
169-172
: LGTM; add an equal-boundary sample.Validates inclusivity in C# as well.
TestContext.WriteLine(Query.CreatedAfter("2023-01-01")); TestContext.WriteLine(Query.CreatedBetween("2023-01-01", "2023-12-31")); + TestContext.WriteLine(Query.CreatedBetween("2023-05-01", "2023-05-01")); TestContext.WriteLine(Query.UpdatedBefore("2023-01-01")); TestContext.WriteLine(Query.UpdatedAfter("2023-01-01")); TestContext.WriteLine(Query.UpdatedBetween("2023-01-01", "2023-12-31")); + TestContext.WriteLine(Query.UpdatedBetween("2023-05-01", "2023-05-01"));tests/languages/ruby/tests.rb (1)
159-162
: LGTM; add equality boundary to assert inclusivity.Keeps parity with other language tests.
puts Query.created_after("2023-01-01") puts Query.created_between('2023-01-01', '2023-12-31') +puts Query.created_between('2023-05-01', '2023-05-01') puts Query.updated_before("2023-01-01") puts Query.updated_after("2023-01-01") puts Query.updated_between('2023-01-01', '2023-12-31') +puts Query.updated_between('2023-05-01', '2023-05-01')tests/languages/dart/tests.dart (1)
161-164
: LGTM; include same-day range to test inclusivity.Matches other suites and clarifies behavior.
print(Query.createdAfter("2023-01-01")); print(Query.createdBetween("2023-01-01", "2023-12-31")); + print(Query.createdBetween("2023-05-01", "2023-05-01")); print(Query.updatedBefore("2023-01-01")); print(Query.updatedAfter("2023-01-01")); print(Query.updatedBetween("2023-01-01", "2023-12-31")); + print(Query.updatedBetween("2023-05-01", "2023-05-01"));templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig (1)
68-69
: Add brief KDoc with expected date format (optional)Documenting expected format (e.g., ISO 8601 date strings) helps users avoid parsing issues.
- fun createdBetween(start: String, end: String) = Query("createdBetween", null, listOf(start, end)).toJson() + /** + * Filter documents by creation timestamp between start and end (inclusive). + * Expected format: YYYY-MM-DD or ISO 8601 string as accepted by the API. + */ + fun createdBetween(start: String, end: String) = Query("createdBetween", null, listOf(start, end)).toJson() ... - fun updatedBetween(start: String, end: String) = Query("updatedBetween", null, listOf(start, end)).toJson() + /** + * Filter documents by update timestamp between start and end (inclusive). + * Expected format: YYYY-MM-DD or ISO 8601 string as accepted by the API. + */ + fun updatedBetween(start: String, end: String) = Query("updatedBetween", null, listOf(start, end)).toJson()Also applies to: 74-75
templates/ruby/lib/container/query.rb.twig (1)
139-142
: Optional: add YARD docs to clarify expected date formatShort docs reduce ambiguity across client languages.
- def created_between(start, ending) + # @param start [String] Start timestamp (e.g., "2023-01-01" or ISO 8601) + # @param ending [String] End timestamp (inclusive) + def created_between(start, ending) return Query.new("createdBetween", nil, [start, ending]).to_s end ... - def updated_between(start, ending) + # @param start [String] Start timestamp (e.g., "2023-01-01" or ISO 8601) + # @param ending [String] End timestamp (inclusive) + def updated_between(start, ending) return Query.new("updatedBetween", nil, [start, ending]).to_s endAlso applies to: 151-154
templates/dotnet/Package/Query.cs.twig (1)
189-192
: Optional: add XML docs (+ typed overloads that format to strings)Docs help consumers; typed overloads can format to API-expected strings without changing wire format.
- public static string CreatedBetween(string start, string end) { + /// <summary> + /// Filter documents by creation timestamp between start and end (inclusive). + /// Expected format: YYYY-MM-DD or ISO 8601 string accepted by the API. + /// </summary> + public static string CreatedBetween(string start, string end) { return new Query("createdBetween", null, new List<string> { start, end }).ToString(); } ... - public static string UpdatedBetween(string start, string end) { + /// <summary> + /// Filter documents by update timestamp between start and end (inclusive). + /// Expected format: YYYY-MM-DD or ISO 8601 string accepted by the API. + /// </summary> + public static string UpdatedBetween(string start, string end) { return new Query("updatedBetween", null, new List<string> { start, end }).ToString(); }Additionally (outside this hunk), consider adding typed convenience overloads:
public static string CreatedBetween(System.DateTime start, System.DateTime end) => CreatedBetween(start.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd")); public static string UpdatedBetween(System.DateTime start, System.DateTime end) => UpdatedBetween(start.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd")); public static string CreatedBetween(System.DateTimeOffset start, System.DateTimeOffset end) => CreatedBetween(start.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd")); public static string UpdatedBetween(System.DateTimeOffset start, System.DateTimeOffset end) => UpdatedBetween(start.ToString("yyyy-MM-dd"), end.ToString("yyyy-MM-dd"));Also applies to: 201-204
templates/android/library/src/main/java/io/package/Query.kt.twig (2)
282-290
: Same KDoc tag nit for updatedBetween.- * @returns The query string. + * @return The query string.
257-265
: Replace@returns
with@return
in the KDoc- * @returns The query string. + * @return The query string.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
composer.lock
is excluded by!**/*.lock
📒 Files selected for processing (31)
example.php
(1 hunks)templates/android/library/src/main/java/io/package/Query.kt.twig
(2 hunks)templates/dart/lib/query.dart.twig
(2 hunks)templates/dart/test/query_test.dart.twig
(2 hunks)templates/deno/src/query.ts.twig
(2 hunks)templates/deno/test/query.test.ts.twig
(2 hunks)templates/dotnet/Package/Query.cs.twig
(2 hunks)templates/go/query.go.twig
(2 hunks)templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig
(1 hunks)templates/php/src/Query.php.twig
(2 hunks)templates/php/tests/QueryTest.php.twig
(1 hunks)templates/python/package/query.py.twig
(2 hunks)templates/react-native/src/query.ts.twig
(2 hunks)templates/ruby/lib/container/query.rb.twig
(2 hunks)templates/swift/Sources/Query.swift.twig
(2 hunks)templates/web/src/query.ts.twig
(2 hunks)tests/languages/android/Tests.kt
(1 hunks)tests/languages/apple/Tests.swift
(1 hunks)tests/languages/dart/tests.dart
(1 hunks)tests/languages/deno/tests.ts
(1 hunks)tests/languages/dotnet/Tests.cs
(1 hunks)tests/languages/flutter/tests.dart
(1 hunks)tests/languages/go/tests.go
(1 hunks)tests/languages/kotlin/Tests.kt
(1 hunks)tests/languages/node/test.js
(1 hunks)tests/languages/php/test.php
(1 hunks)tests/languages/python/tests.py
(1 hunks)tests/languages/ruby/tests.rb
(1 hunks)tests/languages/swift/Tests.swift
(1 hunks)tests/languages/web/index.html
(1 hunks)tests/languages/web/node.js
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/languages/android/Tests.kt (1)
tests/languages/kotlin/Tests.kt (1)
writeToFile
(217-220)
tests/languages/kotlin/Tests.kt (1)
tests/languages/android/Tests.kt (1)
writeToFile
(250-253)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: build (8.3, Swift56)
- GitHub Check: build (8.3, DartStable)
- GitHub Check: build (8.3, KotlinJava17)
- GitHub Check: build (8.3, PHP83)
- GitHub Check: build (8.3, Deno1303)
- GitHub Check: build (8.3, Go112)
- GitHub Check: build (8.3, FlutterStable)
- GitHub Check: build (8.3, DartBeta)
- GitHub Check: build (8.3, Android14Java17)
🔇 Additional comments (38)
tests/languages/go/tests.go (1)
218-224
: Between helpers added — verify date format and boundary behavior
- Confirm CreatedBetween/UpdatedBetween expect plain “YYYY-MM-DD” (not full RFC3339), enforce start ≤ end, and treat both bounds inclusively.
- Add an equal-bounds example to the Go tests, e.g.
fmt.Println(query.CreatedBetween("2023-01-01", "2023-12-31")) +// equal-bounds +fmt.Println(query.CreatedBetween("2023-01-01", "2023-01-01"))tests/languages/web/node.js (1)
195-201
: No duplicatecreatedBetween
orupdatedBetween
in web template
Verified exactly one declaration of each in templates/web/src/query.ts.twig (lines 321–322 and 349–350).tests/languages/python/tests.py (1)
145-151
: Confirm date format and inclusivity; add same-day boundary exampleEnsure
created_between
/updated_between
accept ISO date strings (YYYY-MM-DD
) and verify whether bothstart
andend
are inclusive per the API contract. Consider adding a same-day range example in the tests for clarity:print(Query.created_between('2023-01-01', '2023-12-31')) +print(Query.created_between('2023-01-01', '2023-01-01'))
tests/languages/node/test.js (2)
272-275
: LGTM: createdBetween/updatedBetween smoke calls added.
Matches surrounding style and ordering.
272-275
: Confirm single declarations of createdBetween and updatedBetween
Only one static createdBetween (lines 321–322) and one static updatedBetween (lines 349–350) exist in templates/web/src/query.ts.twig.templates/deno/test/query.test.ts.twig (1)
221-224
: LGTM: adds createdBetween test.
Expected JSON matches existing pattern.templates/swift/Sources/Query.swift.twig (1)
357-363
: LGTM: createdBetween added.
Signature and emitted structure are consistent with createdBefore/After.tests/languages/apple/Tests.swift (1)
195-195
: LGTM: createdBetween covered.
Matches new API.tests/languages/swift/Tests.swift (1)
185-185
: LGTM: createdBetween covered.
Consistent with Swift Query additions.templates/go/query.go.twig (3)
220-226
: LGTM: createdBetween helper matches existing pattern.Consistent with CreatedBefore/After and Between; null attribute and two-value list look correct.
244-250
: LGTM: updatedBetween helper is correct and consistent.Values array shape matches server expectations; no attribute as intended.
220-226
: Verified no duplicate helpers and correct helper presence
Confirmed that all TypeScriptquery.ts.twig
templates contain zero duplicatecreatedBetween
/updatedBetween
declarations, and each of the PHP, Dart, Go, and Python templates defines exactly onecreatedBetween
and oneupdatedBetween
.templates/python/package/query.py.twig (2)
130-133
: LGTM: created_between added correctly.Outputs method "createdBetween" with null attribute and [start, end] values.
142-145
: LGTM: updated_between added correctly.Mirrors created_between semantics.
templates/dart/lib/query.dart.twig (2)
114-117
: LGTM: createdBetween API and docs look good.Inclusive semantics are documented; payload shape is correct.
126-129
: LGTM: updatedBetween API matches createdBetween.Consistent method naming and value handling.
templates/php/src/Query.php.twig (2)
360-363
: LGTM: createdBetween implementation aligns with existing Query conventions.Null attribute and two-element values array are correct.
394-397
: LGTM: updatedBetween implementation mirrors createdBetween.Consistent JSON shape and naming.
templates/php/tests/QueryTest.php.twig (1)
186-189
: Ignore this suggestion: PHP Query helpers return JSON by design
Query::__toString() uses json_encode($this), so tests asserting the JSON shape are correct. Changing the assertion to a DSL string would break existing behavior—if a DSL format is required, update Query::__toString(), not the test.Likely an incorrect or invalid review comment.
templates/deno/src/query.ts.twig (2)
176-185
: LGTM: createdBetween implementation is consistent and type-safeMethod wiring, types, and serialization match existing patterns.
204-213
: LGTM: updatedBetween mirrors createdBetween correctlyConsistent docs, signature, and payload shape.
tests/languages/deno/tests.ts (2)
187-187
: LGTM: exercising createdBetween in output streamKeeps parity with new helper.
190-190
: LGTM: exercising updatedBetween in output streamMatches helper addition.
templates/web/src/query.ts.twig (2)
314-323
: LGTM: createdBetween added with correct serializationMatches existing JSON structure and placement after createdAfter.
342-351
: LGTM: updatedBetween added consistentlyAPI and JSON output are aligned with the rest of the helpers.
tests/languages/web/index.html (2)
264-264
: LGTM: adds createdBetween test invocationParity with other query helpers.
267-267
: LGTM: adds updatedBetween test invocationConsistent with createdBetween addition.
templates/dart/test/query_test.dart.twig (2)
286-291
: createdBetween test — LGTMAssertions match the intended structure (null attribute, two values, correct method).
307-312
: updatedBetween test — LGTMChecks are consistent with other helpers and cover the range values.
templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig (3)
68-69
: Add createdBetween — LGTMSignature and payload shape align with existing conventions.
74-75
: Add updatedBetween — LGTMConsistent with createdBetween and other helpers.
68-75
: No duplicate createdBetween/updatedBetween declarations detectedScan results confirm there are no duplicate
createdBetween
orupdatedBetween
methods across any templates.templates/ruby/lib/container/query.rb.twig (2)
139-142
: Add created_between — LGTMMatches existing style (nil attribute, two values) and avoids the reserved keyword with
ending
.
151-154
: Add updated_between — LGTMConsistent with created_between and the other helpers.
templates/dotnet/Package/Query.cs.twig (2)
189-192
: Add CreatedBetween — LGTMShape matches other helpers and constructor semantics.
201-204
: Add UpdatedBetween — LGTMConsistent with the CreatedBetween addition.
tests/languages/kotlin/Tests.kt (2)
188-188
: Include createdBetween in integration output — LGTMKeeps parity with other query helpers.
191-191
: Include updatedBetween in integration output — LGTMComplements createdBetween coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/Base.php (1)
89-125
: Optional: add edge-case coverage for range validationConsider adding test vectors (in language-specific tests) for invalid ranges (start > end) and boundary-equality cases to ensure consistent, inclusive semantics across SDKs.
Would you like a follow-up patch that adds these cases to each language’s Query tests?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
tests/Base.php
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build (8.3, Ruby31)
- GitHub Check: build (8.3, AppleSwift56)
- GitHub Check: build (8.3, Node20)
🔇 Additional comments (2)
tests/Base.php (2)
122-122
: LGTM: updatedBetween test vector addedMatches the existing updatedBefore/updatedAfter pattern and ordering.
119-119
: Approve code changes ― createdBetween test vector added with correct JSON shape, SDK templates and tests updated, no duplicate definitions found.
What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)
Summary by CodeRabbit