зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1629588 - Ensure we don't setup a new provider if one already exists. r=gvn
Differential Revision: https://phabricator.services.mozilla.com/D70890
This commit is contained in:
Родитель
6a36b46f0d
Коммит
d91ab8e98e
|
@ -57,6 +57,15 @@ this.RecommendationProviderSwitcher = class RecommendationProviderSwitcher {
|
||||||
setAffinityProvider(...args) {
|
setAffinityProvider(...args) {
|
||||||
const { affinityProviderV2 } = this;
|
const { affinityProviderV2 } = this;
|
||||||
if (affinityProviderV2 && affinityProviderV2.modelKeys) {
|
if (affinityProviderV2 && affinityProviderV2.modelKeys) {
|
||||||
|
// A v2 provider is already set. This can happen when new stories come in
|
||||||
|
// and we need to update their scores.
|
||||||
|
// We can use the existing one, a fresh one is created after startup.
|
||||||
|
// Using the existing one might be a bit out of date,
|
||||||
|
// but it's fine for now. We can rely on restarts for updates.
|
||||||
|
// See bug 1629931 for improvements to this.
|
||||||
|
if (this.affinityProvider) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// At this point we've determined we can successfully create a v2 personalization provider.
|
// At this point we've determined we can successfully create a v2 personalization provider.
|
||||||
this.affinityProvider = new PersonalityProvider(...args, {
|
this.affinityProvider = new PersonalityProvider(...args, {
|
||||||
modelKeys: affinityProviderV2.modelKeys,
|
modelKeys: affinityProviderV2.modelKeys,
|
||||||
|
|
|
@ -31,6 +31,7 @@ describe("RecommendationProviderSwitcher", () => {
|
||||||
|
|
||||||
assert.equal(feed.affinityProvider.modelKeys, undefined);
|
assert.equal(feed.affinityProvider.modelKeys, undefined);
|
||||||
|
|
||||||
|
feed.affinityProvider = null;
|
||||||
feed.affinityProviderV2 = {
|
feed.affinityProviderV2 = {
|
||||||
modelKeys: "1234",
|
modelKeys: "1234",
|
||||||
};
|
};
|
||||||
|
@ -45,6 +46,31 @@ describe("RecommendationProviderSwitcher", () => {
|
||||||
|
|
||||||
assert.equal(feed.affinityProvider.modelKeys, "1234");
|
assert.equal(feed.affinityProvider.modelKeys, "1234");
|
||||||
});
|
});
|
||||||
|
it("should use old provider", async () => {
|
||||||
|
feed.setAffinityProvider(
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(feed.affinityProvider.modelKeys, undefined);
|
||||||
|
|
||||||
|
feed.affinityProviderV2 = {
|
||||||
|
modelKeys: "1234",
|
||||||
|
};
|
||||||
|
|
||||||
|
feed.setAffinityProvider(
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(feed.affinityProvider.modelKeys, undefined);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#init", () => {
|
describe("#init", () => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче