Closed Bug 879698 Opened 11 years ago Closed 6 years ago

[Contacts API] Allow 'higherThan' and 'lowerThan' options in nsIContactFindOptions.filterOps

Categories

(Core Graveyard :: DOM: Contacts, defect, P4)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: ferjm, Unassigned)

References

Details

(Keywords: perf, Whiteboard: [c= p= s= u=])

Attachments

(1 file, 1 obsolete file)

After bug 864556 landed, a valid use case for this would be an application locally storing the nsIDOMContact.updated value in its cache and getting the oldest value as soon as its cache revision differs from the Contacts API DB one. In that case, the app could request the list of contacts updated after that date and refresh its cache according to the query result. This way we would avoid forcing the app to get the whole list of contacts.
Assignee: nobody → ferjmoreno
Blocks bug 862385 which is leo+, so leo?
Blocks: 862385
blocking-b2g: --- → leo?
Attached patch wip (obsolete) — Splinter Review
I'd like to write a few more tests before asking for review, but I could use some feedback in the meantime :)
Attachment #758615 - Flags: feedback?(anygregor)
Attachment #758615 - Attachment is patch: true
Attachment #758615 - Attachment mime type: text/x-patch → text/plain
Comment on attachment 758615 [details] [diff] [review]
wip

Review of attachment 758615 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/contacts/fallback/ContactDB.jsm
@@ +362,5 @@
> +        objectStore.createIndex("birthday", "properties.bday", {
> +          multiEntry: true
> +        });
> +        objectStore.createIndex("anniversary", "properties.anniversary", {
> +          multiEntry: true

Bday and anniversary are not arrays, why do you need multiEntry here?

@@ +368,4 @@
>        }
>  
>        // Increment the DB revision on future schema changes as well
> +      if (currVersion > 11) {

You shouldn't change this one, it's supposed to increment the revision for future schema changes, starting from version 10.

@@ +826,5 @@
>      if (DEBUG) debug("ContactDB:find val:" + aOptions.filterValue + " by: " + aOptions.filterBy + " op: " + aOptions.filterOp);
>      let self = this;
>      this.newTxn("readonly", STORE_NAME, function (txn, store) {
> +      let filterOps = ["equals", "contains", "match", "startsWith", "upper",
> +                       "lower"];

Maybe we should go with lessThan and largerThan? Upper and lower makes me think of letter cases.

::: dom/contacts/tests/test_contacts_basics.html
@@ +730,5 @@
> +    req = mozContacts.find(options);
> +    req.onsuccess = function () {
> +      is(req.result.length, 1, "Found exactly 1 contact.");
> +      findResult1 = req.result[0];
> +      ok(findResult1.id == sample_id1, "Same ID");

nit: I know it's not your fault, you just copied the existing tests, but please replace these ok() calls with is() :)
Comment on attachment 758615 [details] [diff] [review]
wip

Review of attachment 758615 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/contacts/fallback/ContactDB.jsm
@@ +354,5 @@
>          };
>        } else if (currVersion == 10) {
>          if (DEBUG) debug("Adding object store for database revision");
>          db.createObjectStore(REVISION_STORE).put(0, REVISION_KEY);
> +      } else if (currVersion == 11) {

You have to check if you already have an objectstore here.

@@ +368,4 @@
>        }
>  
>        // Increment the DB revision on future schema changes as well
> +      if (currVersion > 11) {

We should have a better comment here saying "Don't change"

@@ +888,5 @@
>          let index = store.index("telMatch");
>          let normalized = PhoneNumberUtils.normalize(options.filterValue,
>                                                      /*numbersOnly*/ true);
>          request = index.mozGetAll(normalized, limit);
> +      } else if (options.filterOp ==="upper" || options.filterOp === "lower") {

nit: space after ===
Attachment #758615 - Flags: feedback?(anygregor) → feedback+
(In reply to Fernando Jiménez Moreno [:ferjm] (needinfo instead of CC, please) from comment #1)
> Blocks bug 862385 which is leo+, so leo?

leo+
blocking-b2g: leo? → leo+
Keywords: perf
Whiteboard: c=
Depends on: 882777
Actually, this doesn't block bug 862385 anymore. Sorry for the change of plans.

I'll still work on this though.
No longer blocks: 862385
blocking-b2g: leo+ → leo?
What user scenario would we consider blocking this for at this point? Or is this just leo-
I would say that this is a leo-. Sorry for throwing it again for triage, but I have not the permissions to set the leo- flag myself.
Thanks Fernando, leo-ing per comment 8
blocking-b2g: leo? → ---
Attached patch v1Splinter Review
Attachment #758615 - Attachment is obsolete: true
Attachment #762656 - Flags: review?(anygregor)
Summary: [Contacts API] Allow 'upper' and 'lower' options in nsIContactFindOptions.filterOps → [Contacts API] Allow 'higherThan' and 'lowerThan' options in nsIContactFindOptions.filterOps
Comment on attachment 762656 [details] [diff] [review]
v1

Review of attachment 762656 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good! Thanks!

::: dom/contacts/fallback/ContactDB.jsm
@@ +363,5 @@
> +        }
> +
> +        objectStore.createIndex("published", "published");
> +        objectStore.createIndex("updated", "updated");
> +        objectStore.createIndex("birthday", "properties.bday");

I think we should stick with our field names: bday

::: dom/contacts/tests/test_contacts_basics.html
@@ +1621,5 @@
> +      ok(true, "Expected error");
> +      next();
> +    };
> +  },
> +  function () {

Please also add a test where we filter by "tel" and another field so we end up in the onerror callback.
Attachment #762656 - Flags: review?(anygregor) → review+
Status: NEW → ASSIGNED
Whiteboard: c= → [c= ]
Is this still being worked on?
Flags: needinfo?(ferjmoreno)
I am not currently working on this, so feel free to take it.
Assignee: ferjmoreno → nobody
Flags: needinfo?(ferjmoreno)
Component: DOM: Device Interfaces → DOM: Contacts
Priority: -- → P4
Whiteboard: [c= ] → [c= p= s= u=]
Status: ASSIGNED → NEW
DOM: Contacts isn't used anymore. 
Closing all remaining bugs.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: