Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove /auction Endpoint #2033

Merged
merged 7 commits into from
Oct 18, 2021
Merged

Conversation

SyntaxNode
Copy link
Contributor

@SyntaxNode SyntaxNode commented Oct 5, 2021

!! Do not merge until the release after #2032 !!

Implements phase 3 of #2011. I ran go-lint to find and remove now unused code, and found a few unrelated dead code references which I removed here too.

@@ -77,7 +77,7 @@ func (e *EventListener) Listen(cache stored_requests.Cache, events EventProducer
e.onInvalidate()
}
case <-e.stop:
break
return
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed an unrelated bug. :)

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of nitpicks. Also, the pbs/usersync.go file that contains in the "/optout" endpoint functionality was not removed, can it be relocated to, say endpoints/output.go in a future PR? Or maybe even renamed to captcha/usersync.go or something.

@@ -454,14 +222,6 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque
return bidderResponse, errs
}

func NewIxLegacyAdapter(config *adapters.HTTPAdapterConfig, endpoint string) *IxAdapter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't even used. Good catch.

@@ -31,698 +24,6 @@ func TestJsonSamples(t *testing.T) {
}
}

// Tests for the legacy, non-openrtb code.
// They can be removed after the legacy interface is deprecated.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressed how many lines of code we don't need anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Very satisfying.

@@ -49,16 +31,15 @@ import (
storedRequestsConf "github.com/prebid/prebid-server/stored_requests/config"
"github.com/prebid/prebid-server/usersync"
"github.com/prebid/prebid-server/util/sliceutil"
"github.com/prebid/prebid-server/util/uuidutil"
"github.com/prebid/prebid-server/version"

"github.com/golang/glog"
"github.com/julienschmidt/httprouter"
_ "github.com/lib/pq"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably remove this one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. This is initializing the postgres package which we still use for stored requests. I feel more comfortable experimenting with this in a future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this looks like it's still necessary since it's registering the postgres db driver via the package's init method.

FYI: I personally dislike Go init methods.

@@ -107,7 +107,7 @@ func CreateStoredRequests(cfg *config.StoredRequests, metricsEngine metrics.Metr
//
// As a side-effect, it will add some endpoints to the router if the config calls for it.
// In the future we should look for ways to simplify this so that it's not doing two things.
func NewStoredRequests(cfg *config.Configuration, metricsEngine metrics.MetricsEngine, client *http.Client, router *httprouter.Router) (db *sql.DB, shutdown func(), fetcher stored_requests.Fetcher, ampFetcher stored_requests.Fetcher, accountsFetcher stored_requests.AccountFetcher, categoriesFetcher stored_requests.CategoryFetcher, videoFetcher stored_requests.Fetcher) {
func NewStoredRequests(cfg *config.Configuration, metricsEngine metrics.MetricsEngine, client *http.Client, router *httprouter.Router) (shutdown func(), fetcher stored_requests.Fetcher, ampFetcher stored_requests.Fetcher, accountsFetcher stored_requests.AccountFetcher, categoriesFetcher stored_requests.CategoryFetcher, videoFetcher stored_requests.Fetcher) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove DB connection entry that is no longer returned by this function from the comment above?

 96   // NewStoredRequests returns five things:
 97   //
 98 - // 1. A DB connection, if one was created. This may be nil.
 99   // 2. A function which should be called on shutdown for graceful cleanups.
100   // 3. A Fetcher which can be used to get Stored Requests for /openrtb2/auction
101   // 4. A Fetcher which can be used to get Stored Requests for /openrtb2/amp
102   // 5. A Fetcher which can be used to get Category Mapping data
103   // 6. A Fetcher which can be used to get Stored Requests for /openrtb2/video
104   //
105   // If any errors occur, the program will exit with an error message.
106   // It probably means you have a bad config or networking issue.
107   //
108   // As a side-effect, it will add some endpoints to the router if the config calls for it.
109   // In the future we should look for ways to simplify this so that it's not doing two things.
110   func NewStoredRequests(cfg *config.Configuration, metricsEngine metrics.MetricsEngine, client *http.Client, router *httprouter.Router) (shutdown func(), fetcher stored_requests.Fetcher, ampFetcher store

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'll update the comment. Good catch.

guscarreon
guscarreon previously approved these changes Oct 12, 2021
Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@braizhas
Copy link
Contributor

@SyntaxNode submitted PR SyntaxNode#3 making adform adapter as adf adapter alias. Is such change acceptable here? Should I create separate PR after this one gets merged?

Comment on lines 683 to 729
func TestGetBidTypeVideo(t *testing.T) {
pubmaticExt := new(pubmaticBidExt)
pubmaticExt.BidType = new(int)
*pubmaticExt.BidType = 1
actualBidTypeValue := getBidType(pubmaticExt)
if actualBidTypeValue != openrtb_ext.BidTypeVideo {
t.Errorf("Expected Bid Type value was: %v, actual value is: %v", openrtb_ext.BidTypeVideo, actualBidTypeValue)
}
}

func TestGetBidTypeForMissingBidTypeExt(t *testing.T) {
pubmaticExt := pubmaticBidExt{}
actualBidTypeValue := getBidType(&pubmaticExt)
// banner is the default bid type when no bidType key is present in the bid.ext
if actualBidTypeValue != "banner" {
t.Errorf("Expected Bid Type value was: banner, actual value is: %v", actualBidTypeValue)
}
}

func TestGetBidTypeBanner(t *testing.T) {
pubmaticExt := new(pubmaticBidExt)
pubmaticExt.BidType = new(int)
*pubmaticExt.BidType = 0
actualBidTypeValue := getBidType(pubmaticExt)
if actualBidTypeValue != openrtb_ext.BidTypeBanner {
t.Errorf("Expected Bid Type value was: %v, actual value is: %v", openrtb_ext.BidTypeBanner, actualBidTypeValue)
}
}

func TestGetBidTypeNative(t *testing.T) {
pubmaticExt := new(pubmaticBidExt)
pubmaticExt.BidType = new(int)
*pubmaticExt.BidType = 2
actualBidTypeValue := getBidType(pubmaticExt)
if actualBidTypeValue != openrtb_ext.BidTypeNative {
t.Errorf("Expected Bid Type value was: %v, actual value is: %v", openrtb_ext.BidTypeNative, actualBidTypeValue)
}
}

func TestGetBidTypeForUnsupportedCode(t *testing.T) {
pubmaticExt := new(pubmaticBidExt)
pubmaticExt.BidType = new(int)
*pubmaticExt.BidType = 99
actualBidTypeValue := getBidType(pubmaticExt)
if actualBidTypeValue != openrtb_ext.BidTypeBanner {
t.Errorf("Expected Bid Type value was: %v, actual value is: %v", openrtb_ext.BidTypeBanner, actualBidTypeValue)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add these required test cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reviewing the PR. Good catch. These tests have been restored.

@mansinahar mansinahar removed the request for review from bsardo October 13, 2021 17:12
@SyntaxNode
Copy link
Contributor Author

@SyntaxNode submitted PR SyntaxNode#3 making adform adapter as adf adapter alias. Is such change acceptable here? Should I create separate PR after this one gets merged?

I recommend creating a separate PR after this one gets merged. This PR is already large with 10k+ lines affected.

Copy link
Contributor

@guscarreon guscarreon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mansinahar mansinahar merged commit fe211a9 into prebid:master Oct 18, 2021
mansinahar added a commit that referenced this pull request Oct 18, 2021
SyntaxNode pushed a commit that referenced this pull request Oct 18, 2021
@SyntaxNode
Copy link
Contributor Author

This was accidentally merged earlier than intended. Please see: #2049

jorgeluisrocha pushed a commit to jwplayer/prebid-server that referenced this pull request Sep 28, 2022
jorgeluisrocha pushed a commit to jwplayer/prebid-server that referenced this pull request Sep 28, 2022
shunj-nb pushed a commit to ParticleMedia/prebid-server that referenced this pull request Nov 8, 2022
shunj-nb pushed a commit to ParticleMedia/prebid-server that referenced this pull request Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants