Closed Bug 832936 Opened 8 years ago Closed 8 years ago

[Contacts] mozContacts API should provide a method to easily retrieve how many contacts we have without requesting the contacts list

Categories

(Core :: DOM: Device Interfaces, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24
blocking-b2g -

People

(Reporter: alberto.pastor, Assigned: reuben)

References

Details

(Whiteboard: [fixed-in-birch])

Attachments

(3 files, 1 obsolete file)

In some cases would be useful just retrieve the number of contacts, without retrieving the whole list. If that request is fast enough, I can think on several applications of that method.

No idea if that would be easily included in an standardization process.
CC'ing Gregor and Jonas.

Thoughts?
(In reply to Alberto Pastor from comment #0)
> In some cases would be useful just retrieve the number of contacts, without
> retrieving the whole list. If that request is fast enough, I can think on
> several applications of that method.
> 
> No idea if that would be easily included in an standardization process.

We (bent, sicking reuben and me) had a long discussion about the contacts API performance on Friday.
I am not 100% convinced that our idea we came up with will actually work but we definitely want to improve the current situation and add cursors and a count function.
Pointer to Github pull-request
Attachment #705807 - Attachment is obsolete: true
Knowing if there are no contacts in the DB would help to include some features.
blocking-b2g: --- → leo?
Assignee: nobody → reuben.bmo
(In reply to Alberto Pastor [:albertopq] from comment #4)
> Knowing if there are no contacts in the DB would help to include some
> features.

What features? Required features? Please list bugs impacted with a renom.
blocking-b2g: leo? → -
It is not clear to me which use cases would work better with knowing how many contacts are currently in the DB. Comment 4 is about knowing if there are no contacts in the DB which isn't the same as knowing how many they are...
Alberto, can you clarify the use cases you have in mind here? See comment 6.
Flags: needinfo?(alberto.pastor)
- As Mounir said, checking if you have no contacts for not showing the button "Add to existing contact", for example. I think it makes more sense 
- Any app that want to display the number of contacts without requesting them.
- Pre calculate list containers height for making rendering faster

I don't think is a must, but a nice to have at some point. That's the reason I created a bug for tracking it.
Flags: needinfo?(alberto.pastor)
Ups, the first point was truncated:

- As Mounir said, checking if you have no contacts for not showing the button "Add to existing contact", for example. I think it makes more sense having a "getCount" that an API for knowing if you have no contacts, but is only an opinion from a developer perspective.
I agree that getting the count sounds more useful, and no more complicated to implement or use, than exposing simply "are there contacts or not".
Attached patch Add getCountSplinter Review
Attachment #751233 - Flags: superreview?(jonas)
Attachment #751233 - Flags: review?(jonas)
Attachment #751234 - Flags: review?(anygregor)
Attached patch Test getCountSplinter Review
Attachment #751235 - Flags: review?(anygregor)
Blocks: 872919
Attachment #751234 - Flags: review?(anygregor) → review+
Attachment #751235 - Flags: review?(anygregor) → review+
Attachment #751233 - Flags: superreview?(jonas)
Attachment #751233 - Flags: superreview+
Attachment #751233 - Flags: review?(jonas)
Attachment #751233 - Flags: review+
Thanks!

https://hg.mozilla.org/projects/birch/rev/2c19b63b23d9
Component: General → DOM: Device Interfaces
OS: Mac OS X → All
Product: Boot2Gecko → Core
Hardware: x86 → All
Whiteboard: [fixed-in-birch]
Version: unspecified → Trunk
https://hg.mozilla.org/mozilla-central/rev/2c19b63b23d9
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.