func process(s *session.Session, posts *http.Posts, i int, grp chan *group) {
	for i >= 0 {

		// I don't really have to parse here, forgot kosher implementation.
		// See http/json
		id := strings.Split(posts.Data[i].Id, "_")[1]
		if posts.Data[i].User_has_liked || s.CheckCache(id) || http.IsFollowing(s, id) {
			// Try to add to channel and stop if done
			grp <- &group{
				id: "continue",
			}
			i--
			continue
		}

		//
		user := http.GetUser(s, id)

		// Create perosn to get value
		person := session.Person{
			Followers: float64(user.Data.Counts.Follows),
			Following: float64(user.Data.Counts.Followed_by),
			Posts:     float64(user.Data.Counts.Media),
		}

		// Forget sigmoid for now
		grp <- &group{
			id:    posts.Data[i].Id,
			value: person.Followers / person.Following, // person.Sigmoid(session.GetTheta()) would be the ideal way
			user:  posts.Data[i].User.Username,
		}

		i--
	}
}
Beispiel #2
0
func process(s *session.Session, users *http.Users, i int, follows float64) {
	for i >= 0 {

		id := users.Data[i].Id
		user := http.GetUser(s, id)

		log.Println(user)

		if user.Data.Counts.Followed_by+user.Data.Counts.Follows > 0 {
			//check follower records, if following and guy in other records, don't do anythin
			person := session.Person{
				Followers: float64(user.Data.Counts.Follows),
				Following: float64(user.Data.Counts.Followed_by),
				Posts:     float64(user.Data.Counts.Media),
				Follows:   !s.CheckCache(id),
			}

			// Because unset properties won't change, this should be fine
			if int(follows) == utils.SCORN {
				person.Followed = true
				person.Follows = !person.Follows
			}

			// Add to variable and to Keys
			s.PutPerson(person, id)
		}

		// Decrement
		i--
	}

	// Catches up and thus done
	if s.FinishedCount() {
		s.SavePeople()
		s.StopProcessing()
	}
}