Only make one request for supply point cases

http://manage.dimagi.com/default.asp?115038
Nope, is there any benefit to that approach?


On Tue, Aug 26, 2014 at 4:35 PM, Daniel Miller <notifications@github.com>
wrote:

> In corehq/apps/commtrack/models.py:
>
> > @@ -918,6 +918,23 @@ def to_full_dict(self):
> >          return data
> >
> >      @classmethod
> > +    def get_location_map_by_domain(cls, domain):
> > +        """
> > +        Returns a dict that maps from associated location id's
> > +        to supply point id's for all supply point cases in the passed
> > +        domain.
> > +        """
> > +        kwargs = dict(
> > +            view_name='commtrack/supply_point_by_loc',
> > +            startkey=[domain],
> > +            endkey=[domain, {}],
> > +        )
> > +
> > +        return dict(
> > +            (row['key'][1], row['id']) for row in cls.get_db().view(**kwargs)
> > +        )
>
> Is there a reason you didn't use a dict comprehension?
>
> return {row['key'][1]: row['id'] for row in cls.get_db().view(**kwargs)}
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/dimagi/commcare-hq/pull/4185/files#r16740513>.
>