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

Sync PSF sponsors with logo placement API #10766

Merged
merged 19 commits into from
Feb 21, 2022

Conversation

berinhard
Copy link
Contributor

@berinhard berinhard commented Feb 16, 2022

This PR adds a new scheduled task to keep Pypi's database in sync with Python.org logo placements API. It's scheduled to run every sunday at 03:00 AM. The goal of this work is to centralize sponsors management at pythondotorg and, thus, reduce any type of duplicated work on Pypi side. It also opens the possibility to replace our logo placement by integration with EthicalAds, the same way we did on pythondotorg.

This PR does not handle sidebar, footer, one time or infra structure sponsors. It only operates on top of PSF ones.

I ask reviewers to leave instructions on the new unit tests. I feel that the tests are complex due to pretend and also I feel that probably there's a clever way to mock the task request object.

cc/ @ewdurbin

Copy link
Member

@di di left a comment

Choose a reason for hiding this comment

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

LGTM! Just some small comments

I ask reviewers to leave instructions on the new unit tests. I feel that the tests are complex due to pretend and also I feel that probably there's a clever way to mock the task request object.

Tests look good to me, I think your request fixture is fine.

warehouse/sponsors/tasks.py Outdated Show resolved Hide resolved
warehouse/sponsors/__init__.py Outdated Show resolved Hide resolved
@@ -22,3 +24,8 @@ def _sponsors(request):
def includeme(config):
# Add a request method which will allow to list sponsors
config.add_request_method(_sponsors, name="sponsors", reify=True)

# Add a periodic task to update sponsors table
config.add_periodic_task(
Copy link
Member

Choose a reason for hiding this comment

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

We might want to wrap this in a conditional to check if pythondotorg.api_token is set, then "unconfigure" it in dev. Mostly since I'm going to suggest we run this hourly to reduce the delay for new sponsors and confusion from PSF staff.

@berinhard berinhard force-pushed the feature/sponsors-api-integration branch from 35c1b7e to d9b7ed3 Compare February 18, 2022 13:01
@berinhard
Copy link
Contributor Author

Thanks for your comments! @ewdurbin and @di I added new commits addressing what you've suggested and this PR is probably on a good shape now =)

@ewdurbin ewdurbin merged commit 479e6f3 into pypi:main Feb 21, 2022
domdfcoding pushed a commit to domdfcoding/warehouse that referenced this pull request Jun 7, 2022
* Add new config variables to integrate with pythondotorg

* Add new fields with data from pythondotorg logo placement API

* Register task to update sponsors table

* Code linter

* Fix typo

* Minimal working code to integrate with logo palcement endpoint

* First unit test to figure out how to mock requests

* Create a new sponsor

* Add logic to update existing sponsors

* Reformat code

* Leave HTTP vs HTTPS configuration to be handle by env variable

* Fix linter errors

* Create sponsor directly from the exception handler

* Run task every 10 minutes

* There's no need for the if condition

* Only schedule cron job if there's a token in the env

* Remove pythondotorg env variables from dev

* Run linter

Co-authored-by: Ee Durbin <ewdurbin@gmail.com>
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.

3 participants