importer/foursquare: import also the photo of the companion

Change-Id: Ia7d60ed049a038fb1b729230ed9eb817b400b076
This commit is contained in:
Kate Pek 2016-04-30 09:52:43 -05:00
parent 0c7fd08d49
commit 9122259e66
4 changed files with 18 additions and 0 deletions

View File

@ -22,6 +22,7 @@ type user struct {
Id string
FirstName string
LastName string
Photo photoItem
}
type userInfo struct {
@ -87,6 +88,13 @@ func (vi *venueItem) icon() string {
return c.Icon.Prefix + "bg_88" + c.Icon.Suffix
}
func (user *user) icon() string {
if user.Photo.Prefix == "" || user.Photo.Suffix == "" {
return ""
}
return user.Photo.Prefix + "500x500" + user.Photo.Suffix
}
type venueLocationItem struct {
Address string
City string

View File

@ -385,10 +385,12 @@ func (r *run) importCompanions(parent *importer.Object, companions []*user) (com
if err != nil {
return nil, err
}
icon := user.icon()
if err := personNode.SetAttrs(
attrFoursquareId, user.Id,
nodeattr.Type, "foursquare.com:person",
nodeattr.Title, user.FirstName+" "+user.LastName,
nodeattr.CamliContentImage, r.urlFileRef(icon, path.Base(icon)),
nodeattr.GivenName, user.FirstName,
nodeattr.FamilyName, user.LastName); err != nil {
return nil, err

View File

@ -42,6 +42,10 @@ func TestGetUserId(t *testing.T) {
Id: "13674",
FirstName: "Brad",
LastName: "Fitzpatrick",
Photo: photoItem{
Prefix: "https://irs0.4sqi.net/img/user/",
Suffix: "/CKG5FOF2WMCMPD3E.jpg",
},
}
if inf != want {
t.Errorf("user info = %+v; want %+v", inf, want)

View File

@ -170,6 +170,10 @@ func fakeCheckinsList(offset, maxCheckin int, towns map[int]*venueLocationItem,
Id: "123",
FirstName: "Kate",
LastName: "Pek",
Photo: photoItem{
Prefix: "https://irs3.4sqi.net/img/user/",
Suffix: "/13674-S2IUMHALCCJJUTQO.jpg",
},
},
},
CreatedAt: time.Now().Unix(),