func Collect(session *stackongo.Session, appInfo AppDetails, params stackongo.Params) (*stackongo.Questions, error) { params.Add("key", appInfo.Key) params.Add("filter", appInfo.Filters) params.Add("site", "stackoverflow") return session.AllQuestions(params) }
// Return questions based on ids func GetQuestionsByIDs(session *stackongo.Session, ids []int, appInfo AppDetails, params stackongo.Params) (*stackongo.Questions, error) { // Add standard parameters params = addParams(appInfo, params) questions := &stackongo.Questions{Quota_remaining: 2} startIndex, endIndex := 0, 100 for endIndex < len(ids) && questions.Quota_remaining > 1 { // Search for questions newSearch, err := session.GetQuestions(ids[startIndex:endIndex], params) if err != nil { return nil, fmt.Errorf("Failed at ln 57 of dataCollect: %v", err.Error()) } if questions.Error_id != 0 { return nil, fmt.Errorf("%v: %v", questions.Error_name, questions.Error_message) } newSearch.Items = append(questions.Items, newSearch.Items...) questions = newSearch startIndex = endIndex endIndex += 100 } newSearch, err := session.GetQuestions(ids[startIndex:], params) if err != nil { return nil, fmt.Errorf("Failed at ln 57 of dataCollect: %v", err.Error()) } if questions.Error_id != 0 { return nil, fmt.Errorf("%v: %v", questions.Error_name, questions.Error_message) } newSearch.Items = append(questions.Items, newSearch.Items...) questions = newSearch return questions, nil }