func (s *Server) handleRepopulateSearchDocuments(w http.ResponseWriter, r *http.Request) error {
	limit := parseLimitParam(r, 100)
	beforeParam := r.FormValue("before")
	if beforeParam == "" {
		return &serverError{
			http.StatusBadRequest,
			errors.New("must provide 'before' query param as an RFC3339 datetime"),
		}
	}
	before, err := time.Parse(time.RFC3339, beforeParam)
	if err != nil {
		return &serverError{http.StatusBadRequest, err}
	}

	ctx := r.Context()
	log.Infof(ctx, "Repopulating search documents for %d packages", limit)
	sdargs, err := s.db.GetPackagesForSearchDocumentUpsert(ctx, before, limit)
	if err != nil {
		return err
	}

	for _, args := range sdargs {
		if err := postgres.UpsertSearchDocument(ctx, s.db.Underlying(), args); err != nil {
			return err
		}
	}
	return nil
}
// handleRepopulateSearchDocuments repopulates every row in the search_documents table
// that was last updated before the given time.
handleRepopulateSearchDocuments repopulates every row in the search_documents table
that was last updated before the given time.
// handleRepopulateSearchDocuments repopulates every row in the search_documents table // that was last updated before the given time .
func (s *Server) handleRepopulateSearchDocuments(w http.ResponseWriter, r *http.Request) error {
	limit := parseLimitParam(r, 100)
	beforeParam := r.FormValue("before")
	if beforeParam == "" {
		return &serverError{
			http.StatusBadRequest,
			errors.New("must provide 'before' query param as an RFC3339 datetime"),
		}
	}
	before, err := time.Parse(time.RFC3339, beforeParam)
	if err != nil {
		return &serverError{http.StatusBadRequest, err}
	}
	ctx := r.Context()
	log.Infof(ctx, "Repopulating search documents for %d packages", limit)
	sdargs, err := s.db.GetPackagesForSearchDocumentUpsert(ctx, before, limit)
	if err != nil {
		return err
	}
	for _, args := range sdargs {
		if err := postgres.UpsertSearchDocument(ctx, s.db.Underlying(), args); err != nil {
			return err
		}
	}
	return nil
}
func ( s * Server ) handleRepopulateSearchDocuments ( w http . ResponseWriter , r * http . Request ) error { limit := parseLimitParam ( r , 100 ) beforeParam := r . FormValue ( " " ) if beforeParam == " " { return & serverError { http . StatusBadRequest , errors . New ( " " ) , } } before , err := time . Parse ( time . RFC3339 , beforeParam ) if err != nil { return & serverError { http . StatusBadRequest , err } } ctx := r . Context ( ) log . Infof ( ctx , " " , limit ) sdargs , err := s . db . GetPackagesForSearchDocumentUpsert ( ctx , before , limit ) if err != nil { return err } for _ , args := range sdargs { if err := postgres . UpsertSearchDocument ( ctx , s . db . Underlying ( ) , args ) ; err != nil { return err } } return nil }
handleRepopulateSearchDocuments repopulates every row in the search_documents table
that was last updated before the given time.
handleRepopulateSearchDocuments repopulates every row in the search_documents table that was last updated before the given time .