End a campaign by comparing end date and system time
- Maniphest Tasks
- T89452: Start and end campaign automatically at specified time
• Niharika bd808
- Patch without arc
- git checkout -b D953 && curl -L https://phabricator.wikimedia.org/D953?download=true | git apply
I'm not a fan of this approach. This makes database changes based on an HTTP GET request. The GET verb should ideally be idempotent (not cause any state changes). It also adds N+1 to 2N+1 database queries to each view of the landing page where N is the number of existing campaigns.
The change I expected is to stop using the status field in the campaigns table entirely and instead replace it with a comparison between the current server time and the campaigns.end_date value. Since we don't have a true model object for the campaigns and instead pass around arrays of data it may be easiest to actually compute the binary status inside Wikimedia\IEGReview\Dao\Campaigns when retrieving campaign information. One way to do this would be to use a phrase like CAST(end_date < NOW() AS INT) AS status in the SELECT statements.
endCampaign is still used in Wikimedia\IEGReview\Controllers\Admin\CampaignEnd.