Searching for optimal method for X most recently active Gmail threads (via IMAP)

27 views
Skip to first unread message

Mark McLaren

unread,
Sep 19, 2011, 10:04:07 AM9/19/11
to google-app...@googlegroups.com

I previously posted my query to google-mail-xoauth-tools but have been advised to post my query here as it is an official forum and is actively monitored by Google Developer Relations.

 I've compared the speed that the Gmail Atom Inbox thread feed is generated with an equivalent behaviour using Gmail IMAP and found Atom feed to be significantly faster.  I appreciate these are labs features and probably not officially supported.

 I am looking for the optimal way to acquire a list of the top X most recently active Gmail threads.  I am using Java, XOAUTH and the Gmail IMAP Extensions [X-GM-EXT-1].  I see that the Google App Script provides functionality that would be really useful for this "getInboxThreads(start, max)".

 Is there a better way than iterating through the INBOX until X distinct message threads have been identified?

http://stackoverflow.com/q/7322001/292219

Any advice gratefully received.  Many thanks,

Mark

Rufus

unread,
Sep 23, 2011, 7:26:40 PM9/23/11
to Google Apps Domain Information and Management APIs
Hi Mark,

Have you tried using X-GM-RAW (http://code.google.com/apis/gmail/imap/
#x-gm-raw) for a search of a label and a date?
You could query on "label:inbox after:YYYYMMDD" where YYYYMMDD is the
last day you checked (granularity on this search is to the day, not
the hour).
Then you could go through the return set to find the most recent X
threads among the mails. You could skip the "lable:inbox" to search
all email.

I'm not a Gmail guru, but this looks like a way to narrow down what
you iterate over.

Also, if you could talk a little more about what you would like to do
with the X most recent threads, maybe we could think of another
approach.

/Rufus

more tips on searches: https://mail.google.com/support/bin/answer.py?answer=7190

Mark McLaren

unread,
Sep 23, 2011, 7:48:44 PM9/23/11
to google-app...@googlegroups.com
Hi Rufus,

Thank you for replying.

I'm currently accessing Gmail via IMAP to display an inbox summary in
our enterprise student portal (accessing the student's inbox by proxy
using 2 legged OAuth).

I want to show the last 40 threads (arbitrary choice) including read
threads. I download some number of messages (e.g. 40 x 4) and
initially I just fetch the X-GM-THRID value. I iterate through these
message X-GM-THRID values (and fetch more messages if necessary) until
I reach my target or there are no more messages in the inbox.

Once I have my list of 40 X-GM-THRID values I run "SEARCH X-GM-THRID"
to fetch only the e-mails in those threads. I can then determine
original thread subject line, if any flags are set, read/unread
status, number of messages in the threads and such like. We plan on
getting SAML working with our single sign-on solution (JASIG CAS) so
that we can provide a seamless experience between our portal (uPortal)
and Google Apps.

Cheers,

Mark

> --
> You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group.
> To post to this group, send email to google-app...@googlegroups.com.
> To unsubscribe from this group, send email to google-apps-mgmt...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-apps-mgmt-apis?hl=en.
>
>

--
"Paradoxically, the more time saving abstractions you are using the
more you actually have to know." - Simon Willison

Alexandre Jacquet

unread,
Sep 24, 2011, 9:06:53 AM9/24/11
to google-app...@googlegroups.com

Have you tried the new gmail feeed it was released this week

Mark McLaren

unread,
Sep 24, 2011, 9:20:08 AM9/24/11
to google-app...@googlegroups.com
Hi Alexandre,

That sounds interesting. I've tried the atom feed
(http://code.google.com/apis/gmail/docs/inbox_feed.html). It is fast
but not fully featured.

Is that it that what you mean or is there an even newer one?

Thanks,

Mark

Alexandre Jacquet

unread,
Sep 24, 2011, 11:01:17 AM9/24/11
to google-app...@googlegroups.com
Yes, is this one that you have tested ;(


Sorry

                                                                                           

Alexandre Jacquet

Google Apps Deployment Specialst 
São Paulo | SP | Brasil
Tel.: 55 11 8064 6882

Reply all
Reply to author
Forward
0 new messages