Beispiel #1
0
func GetNewQns(fromDate time.Time, toDate time.Time) (*stackongo.Questions, error) {
	// Set starting variable parameters
	// Adding parameters to request
	params := make(stackongo.Params)
	params.Pagesize(100)
	params.Fromdate(fromDate)
	params.Todate(toDate)
	params.Sort("creation")
	params.Add("accepted", false)
	params.AddVectorized("tagged", tags)

	questions := new(stackongo.Questions)
	questions.Has_more = true
	appInfo.Quota_remaining = 1
	page := 0

	for questions.Has_more && appInfo.Quota_remaining > 0 {
		page++
		params.Page(page)

		nextPage, err := dataCollect.Collect(session, appInfo, params)
		if err != nil {
			return nil, errors.New("Error collecting questions\t" + err.Error())
		}

		appInfo.Quota_remaining = nextPage.Quota_remaining
		if nextPage.Error_id != 0 {
			return nil, errors.New("Request error:\t" + questions.Error_name + ": " + questions.Error_message)
		}
		nextPage.Items = append(questions.Items, nextPage.Items...)
		questions = nextPage
	}
	return questions, nil
}
Beispiel #2
0
// Returns StackOverflow questions asked between fromDate and toDate
func GetNewQns(fromDate time.Time, toDate time.Time) (*stackongo.Questions, error) {
	// Adding parameters to request
	params := make(stackongo.Params)
	params.Pagesize(100)
	params.Fromdate(fromDate)
	params.Todate(toDate)
	params.Sort("creation")
	params.Add("accepted", false)
	params.Add("closed", false)

	// Add questions tagged with "google-places-api"
	params.Add("tagged", tags[0])
	questions, err := dataCollect.Collect(appInfo, params, transport)
	if err != nil {
		return nil, err
	}

	// Return if no quota remaining for the app
	if questions.Quota_remaining <= 0 {
		return questions, fmt.Errorf("No StackExchange requests remaining")
	}

	// Add questions tagged with "google-places"
	params.Add("tagged", tags[1])
	params.Add("nottagged", tags[0])
	tagQuestions, err := dataCollect.Collect(appInfo, params, transport)
	if err != nil {
		return questions, err
	}
	tagQuestions.Items = append(questions.Items, tagQuestions.Items...)
	questions = tagQuestions
	sort.Sort(byCreationDate(questions.Items))

	// Return if no quota remaining for the app
	if questions.Quota_remaining <= 0 {
		return questions, fmt.Errorf("No StackExchange requests remaining")
	}

	// Add questions with "Places API" in the body
	params.Del("tagged")
	params.Add("body", keyWords)
	params.AddVectorized("nottagged", tags)
	bodyQuestions, err := dataCollect.Collect(appInfo, params, transport)
	if err != nil {
		return questions, err
	}
	bodyQuestions.Items = append(questions.Items, bodyQuestions.Items...)
	questions = bodyQuestions
	sort.Sort(byCreationDate(questions.Items))

	// Return if no quota remaining for the app
	if questions.Quota_remaining <= 0 {
		return questions, fmt.Errorf("No StackExchange requests remaining")
	}

	// Add questions with "Places API" in the body
	params.Del("body")
	params.Add("title", keyWords)
	titleQuestions, err := dataCollect.Collect(appInfo, params, transport)
	if err != nil {
		return questions, err
	}
	titleQuestions.Items = append(questions.Items, titleQuestions.Items...)
	questions = titleQuestions
	sort.Sort(byCreationDate(questions.Items))

	return questions, nil
}
Beispiel #3
0
// Return questions based on search parameters
func NewSearch(r *http.Request, params stackongo.Params) (*stackongo.Questions, error) {
	return dataCollect.Collect(appInfo, params, transport)
}
Beispiel #4
0
func NewSearch(r *http.Request, params stackongo.Params) (*stackongo.Questions, error) {
	return dataCollect.Collect(session, appInfo, params)
}