profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/thebrianchen/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

gavinc95/alexa-recipe 0

A simple Alexa Skill that guides you through recipes from DynamoDB

ryannma/firstnet 0

Repository for the AT&T Firstnet Hackathon Mar 23 - Mar 24, 2018

saasbook/city-dog-share-calendar 0

City Dog Share Calendar App

thebrianchen/conformance-tests 0

GoogleAPIs client library conformance tests

push eventfirebase/firebase-android-sdk

Brian Chen

commit sha e5fdd37f41c94f82734464831635a96c3eb4dbcf

resolve comments

view details

push time in a day

Pull request review commentfirebase/firebase-android-sdk

add update time to FieldIndex

 public void testCollectionGroup() {     verifyResults(query, "coll1/doc1", "coll2/doc2/coll1/doc1");   } +  @Test+  public void testUpdateTime() {+    indexManager.addFieldIndex(+        new FieldIndex("coll1")+            .withAddedField(field("value"), FieldIndex.Segment.Kind.ORDERED)+            .withUpdateTime(new Timestamp(10, 20)));++    List<FieldIndex> indexes = ((SQLiteIndexManager) indexManager).getFieldIndexes();+    assertEquals(indexes.size(), 1);+    FieldIndex index = indexes.get(0);+    assertEquals(index.getUpdateTime(), new Timestamp(10, 20));+  }

The test here checks that the persistence queries in addFieldIndex and getFieldIndex are correct.

thebrianchen

comment created time in a day

Pull request review commentfirebase/firebase-android-sdk

add update time to FieldIndex

 public boolean equals(Object o) {     FieldIndex fieldIndex = (FieldIndex) o;      if (!segments.equals(fieldIndex.segments)) return false;-    return collectionId.equals(fieldIndex.collectionId);+    return collectionGroup.equals(fieldIndex.collectionGroup);

done.

thebrianchen

comment created time in a day

Pull request review commentfirebase/firebase-android-sdk

add update time to FieldIndex

 public boolean equals(Object o) {     FieldIndex fieldIndex = (FieldIndex) o;      if (!segments.equals(fieldIndex.segments)) return false;-    return collectionId.equals(fieldIndex.collectionId);+    return collectionGroup.equals(fieldIndex.collectionGroup);   }    @Override   public int hashCode() {-    int result = collectionId.hashCode();+    int result = collectionGroup.hashCode();     result = 31 * result + segments.hashCode();     return result;   }    @Override   public String toString() {-    return String.format("FieldIndex{collectionId='%s', segments=%s}", collectionId, segments);+    return String.format(+        "FieldIndex{collectionGroup='%s', segments=%s}", collectionGroup, segments);

done.

thebrianchen

comment created time in a day

Pull request review commentfirebase/firebase-android-sdk

add update time to FieldIndex

 public Index encodeFieldIndex(FieldIndex fieldIndex) {     return index.build();   } -  public FieldIndex decodeFieldIndex(String collection_group, int indexId, Index index) {-    FieldIndex fieldIndex = new FieldIndex(collection_group, indexId);+  public FieldIndex decodeFieldIndex(+      String collectionGroup, int indexId, Index index, int updateSeconds, int updateNanos) {

done.

thebrianchen

comment created time in a day

Pull request review commentfirebase/firebase-android-sdk

add update time to FieldIndex

 public boolean equals(Object o) {     FieldIndex fieldIndex = (FieldIndex) o;      if (!segments.equals(fieldIndex.segments)) return false;-    return collectionId.equals(fieldIndex.collectionId);+    return collectionGroup.equals(fieldIndex.collectionGroup);   }    @Override   public int hashCode() {-    int result = collectionId.hashCode();+    int result = collectionGroup.hashCode();

done.

thebrianchen

comment created time in a day

PullRequestReviewEvent
PullRequestReviewEvent

PR opened firebase/firebase-android-sdk

Reviewers
add update time to FieldIndex api: firestore

Incremental PR to add storing and retrieving last update time from FieldIndex. Also renamed collectionId to collectionGroup on fieldIndex.

+89 -22

0 comment

5 changed files

pr created time in a day

push eventfirebase/firebase-android-sdk

Brian Chen

commit sha 2cdef90113b5701b8d8aa3aaa701e303de85a9c8

add update time to FieldIndex

view details

push time in a day

create barnchfirebase/firebase-android-sdk

branch : bc/field-index-update-times

created branch time in a day

issue closedfirebase/firebase-js-sdk

Firestore Lite : TypeError: Cannot read property 'indexOf' of undefined

Error

I am getting the following error while using the new firebase web SDK in Vue 3 SSR.

TypeError: Cannot read property 'indexOf' of undefined
    at Function.ResourcePath.fromString (........./node_modules/@firebase/firestore/dist/lite/index.node.cjs.js:857:22)

The errors need to be a little bit more descriptive. Faced an issue a few days ago as well when the error that was thrown was very vague.

Configs

  • Firebase Version: 9.0.2
  • App: Vue 3 SSR

Relevant Code:

import { initializeApp } from "firebase/app";
import {
  initializeAuth,
  onAuthStateChanged,
  signInWithEmailAndPassword,
  inMemoryPersistence,
  indexedDBLocalPersistence,
  browserLocalPersistence,
  signOut,
  sendPasswordResetEmail,
  createUserWithEmailAndPassword,
} from "firebase/auth";
import {
  getFirestore,
  getDocs,
  doc,
  getDoc,
  where,
  collection,
  query,
  orderBy,
  setDoc,
  limit,
} from "firebase/firestore/lite";

import config from "./config.js";

const firebaseApp = initializeApp(config.firebase_config);
const db = getFirestore(firebaseApp);
const auth = initializeAuth(firebaseApp, {
  persistence:
    typeof window === "undefined"
      ? inMemoryPersistence
      : [indexedDBLocalPersistence, browserLocalPersistence]
});

export {
  db,
  auth,
  getDocs,
  setDoc,
  query,
  orderBy,
  doc,
  getDoc,
  where,
  collection,
  onAuthStateChanged,
  signInWithEmailAndPassword,
  signOut,
  sendPasswordResetEmail,
  limit,
  createUserWithEmailAndPassword,
};

closed time in a day

arneesh

issue commentfirebase/firebase-js-sdk

Firestore Lite : TypeError: Cannot read property 'indexOf' of undefined

@arneesh You are probably getting this error from passing in undefined values as path segments when creating collections of documents. Firestore's typings are provided in TS and guard against errors like these. We made the decision to remove validation code for types that would be guarded by TS in order to reduce the overall size of the package.

I'm going to mark this issue as closed, but feel free to ask any other questions you may have!

arneesh

comment created time in a day

issue commentfirebase/firebase-android-sdk

Firestore - Failed to get documents from server

@Monabr Can you also enable logging and share the stack trace of the error and its subsequent attempts to reconnect?

You can enable Firestore debug logging by calling FirebaseFirestore.setLoggingEnabled(true) prior to reproducing the error.

Monabr

comment created time in a day

Pull request review commentfirebase/firebase-android-sdk

Change Bound's before to inclusive

 public String getCanonicalId() {      if (startAt != null) {       builder.append("|lb:");-      builder.append(startAt.canonicalString());+      builder.append(startAt.isInclusive() ? "b:" : "a:");

optional: move this ternary into a method on Bound.

schmidt-sebastian

comment created time in 2 days

Pull request review commentfirebase/firebase-android-sdk

Change Bound's before to inclusive

 public String canonicalString() {    /** Returns true if a document sorts before a bound using the provided sort order. */   public boolean sortsBeforeDocument(List<OrderBy> orderBy, Document document) {+    int comparison = compareToDocument(orderBy, document);+    return inclusive ? comparison <= 0 : comparison < 0;+  }++  /** Returns true if a document sorts after a bound using the provided sort order. */

readability request: can you include this comment somewhere in the class to save future us from going through this again?

schmidt-sebastian

comment created time in 2 days

Pull request review commentfirebase/firebase-android-sdk

Change Bound's before to inclusive

 public void testEncodesLimits() {   public void testEncodesBounds() {     Query q =         Query.atPath(ResourcePath.fromString("docs"))-            .startAt(new Bound(asList(Values.refValue(databaseId, key("foo/bar"))), true))-            .endAt(new Bound(asList(Values.refValue(databaseId, key("foo/baz"))), false));+            .startAt(bound(true, refValue(databaseId, key("foo/bar"))))

optional: include code comment for true value here and throughout

schmidt-sebastian

comment created time in 2 days

Pull request review commentfirebase/firebase-android-sdk

Change Bound's before to inclusive

 public void addIndexEntries(Document document) {     if (fieldIndex == null) return null;      Bound lowerBound = target.getLowerBound(fieldIndex);-    String lowerBoundOp = lowerBound.isBefore() ? ">=" : ">"; // `startAt()` versus `startAfter()`+    String lowerBoundOp = lowerBound.isInclusive() ? ">=" : ">";

this cleanness makes everything worth it.

schmidt-sebastian

comment created time in 2 days

Pull request review commentfirebase/firebase-android-sdk

Change Bound's before to inclusive

 private int decodeLimit(JSONObject structuredQuery) {     }   } -  private Bound decodeBound(@Nullable JSONObject bound) throws JSONException {+  private Bound decodeStartAtBound(@Nullable JSONObject bound) throws JSONException {

Hm. I wonder if we can offload the duplicated logic into decodePosition, or if that just gets us back to the same level of misdirection.

schmidt-sebastian

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentfirebase/firebase-android-sdk

Tighten the query bounds

 public void testStartAfterFilter() {   }    @Test-  public void testEndAtFilter() {+  public void testEndBeforeFilter() {

oh man this still doesn't make too much sense... Still can't wrap my mind around how endBefore has before set to false in order to mean that the cursor stops before??

Is this documented anywhere? optional nice thing you can do is encapsulate the before bound stuff into some tester objects :)

schmidt-sebastian

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentfirebase/firebase-android-sdk

Tighten the query bounds

 public static Value refValue(DatabaseId databaseId, DocumentKey key) {             .build();     return value;   }++  public static Value getFirstValue(Value.ValueTypeCase valueTypeCase) {+    switch (valueTypeCase) {+      case NULL_VALUE:+        return Values.NULL_VALUE;+      case BOOLEAN_VALUE:+        return Value.newBuilder().setBooleanValue(false).build();+      case INTEGER_VALUE:+      case DOUBLE_VALUE:+        return Value.newBuilder().setDoubleValue(Double.NaN).build();+      case TIMESTAMP_VALUE:+        return Value.newBuilder()+            .setTimestampValue(Timestamp.newBuilder().setSeconds(Long.MIN_VALUE))+            .build();+      case STRING_VALUE:+        return Value.newBuilder().setStringValue("").build();+      case BYTES_VALUE:+        return Value.newBuilder().setBytesValue(ByteString.EMPTY).build();+      case REFERENCE_VALUE:+        return refValue(DatabaseId.EMPTY, DocumentKey.empty());+      case GEO_POINT_VALUE:+        return Value.newBuilder()+            .setGeoPointValue(LatLng.newBuilder().setLatitude(-90.0).setLongitude(-180.0))+            .build();+      case ARRAY_VALUE:+        return Value.newBuilder().setArrayValue(ArrayValue.getDefaultInstance()).build();+      case MAP_VALUE:+        return Value.newBuilder().setMapValue(MapValue.getDefaultInstance()).build();+      default:+        throw new IllegalArgumentException("Unknown value type: " + valueTypeCase);+    }+  }++  public static @Nullable Value getNextValue(Value.ValueTypeCase valueTypeCase) {

Some ideas: getHighestValueExclusive, getUpperBoundExclusive, getExclusiveUpperBound

I think pairing "exclusive" with a "bound" makes more sense. Or you can leave the current name and just have comments.

schmidt-sebastian

comment created time in 3 days

Pull request review commentfirebase/firebase-android-sdk

Tighten the query bounds

 public static Value refValue(DatabaseId databaseId, DocumentKey key) {             .build();     return value;   }++  public static Value getFirstValue(Value.ValueTypeCase valueTypeCase) {+    switch (valueTypeCase) {+      case NULL_VALUE:+        return Values.NULL_VALUE;+      case BOOLEAN_VALUE:+        return Value.newBuilder().setBooleanValue(false).build();+      case INTEGER_VALUE:+      case DOUBLE_VALUE:+        return Value.newBuilder().setDoubleValue(Double.NaN).build();+      case TIMESTAMP_VALUE:+        return Value.newBuilder()+            .setTimestampValue(Timestamp.newBuilder().setSeconds(Long.MIN_VALUE))+            .build();+      case STRING_VALUE:+        return Value.newBuilder().setStringValue("").build();+      case BYTES_VALUE:+        return Value.newBuilder().setBytesValue(ByteString.EMPTY).build();+      case REFERENCE_VALUE:+        return refValue(DatabaseId.EMPTY, DocumentKey.empty());+      case GEO_POINT_VALUE:+        return Value.newBuilder()+            .setGeoPointValue(LatLng.newBuilder().setLatitude(-90.0).setLongitude(-180.0))+            .build();+      case ARRAY_VALUE:+        return Value.newBuilder().setArrayValue(ArrayValue.getDefaultInstance()).build();+      case MAP_VALUE:+        return Value.newBuilder().setMapValue(MapValue.getDefaultInstance()).build();+      default:+        throw new IllegalArgumentException("Unknown value type: " + valueTypeCase);+    }+  }++  public static @Nullable Value getNextValue(Value.ValueTypeCase valueTypeCase) {

s/getNextValue/getHighestValue or getHighestPossibleValue?

NextValue is a bit confusing here. Alternatively, just add some code comments please.

schmidt-sebastian

comment created time in 3 days

Pull request review commentfirebase/firebase-android-sdk

Tighten the query bounds

 public static Value refValue(DatabaseId databaseId, DocumentKey key) {             .build();     return value;   }++  public static Value getFirstValue(Value.ValueTypeCase valueTypeCase) {

s/getFirstValue/getLowestValue?

schmidt-sebastian

comment created time in 3 days

PullRequestReviewEvent

Pull request review commentfirebase/firebase-android-sdk

Tighten the query bounds

 public void testStartAfterFilter() {   }    @Test-  public void testEndAtFilter() {+  public void testEndBeforeFilter() {

I'm a little confused about the before in Bound. Based on the naming of this test, if before == true, Bound does not include the endAt value? However, it seems like it's flipped for startAt and startAfter.

I find a it harder to reason about before/after since it's flipped for whether it's a startAt, or endAt. Is it possible to change it before to an inclusive/exclusive model instead?

schmidt-sebastian

comment created time in 3 days

Pull request review commentfirebase/firebase-android-sdk

Tighten the query bounds

 public Bound getLowerBound(FieldIndex fieldIndex) {     // Go through all filters to find a value for the current field segment     for (FieldIndex.Segment segment : fieldIndex) {       Value lowestValue = Values.NULL_VALUE;+       for (Filter filter : filters) {         if (filter.getField().equals(segment.getFieldPath())) {           FieldFilter fieldFilter = (FieldFilter) filter;++          Value newValue = null;

optional: s/new/current for here and below?

When looking at newValue, I initially thought that this value was going to be assigned because of the new, but it seems like it's only evaluated to be compared to the outer lowestValue.

schmidt-sebastian

comment created time in 3 days