= Implementation details
Create a way to fetch the number of views to articles that embed files that were uploaded during the event, and display them as 'average daily views'.
The query should:
* Fetch all files that were uploaded to Commons **and** to the local wikis specified in the event setting (the system currently //only// considers uploads to commons; this new method needs to add the ability to fetch the list of files uploaded to the local wikis too)
** There is a task to track uploads from the individual wiki (expanding the collection from Commons only) at task {T206819}
** That task is slightly broader (to enable using all metrics about uploads to show local wiki as well) but depending on your implementation approach, may need to be done before this current task.
* For each of those uploaded files, get the articles they are used/embedded in. Article list should be unique (even if two files were uploaded to the same article, the article should be counted once)
* For each of those articles, fetch the monthly page views.
** For articles that are older than 30 days, divide the monthly page views by 30.
** For articles that are "younger" than 30 days (were created less than 30 days ago) -- divide the monthly number by the number of days the article exists.
* Add all individual average views to one big sum average view, and return it
= Deeper dive
===Why we're doing this
Organizers, their sponsors and partners want to understand the impact of their work. One main way to do this for files uploaded is to see the number of pageviews those files get on the various article pages to which they are added. This figure will be reported in the Event Summary reports (T205561 and T206692 ); it will also be used in the to-be-defined Files Uploaded report.
In our discussions, it has become clear that we can't get an accurate cumulative pageviews figure because we don't know the dates when specific files were added to specific articles. So instead, we will be providing a figure for "average daily pageviews".
=== Parameters
- **All filetypes:** The figure will track images, video files, audio files and other upload types.
- **Uploads to Commons //and// local Wikipedias: ** We will track uploads to all wikis, so long as they are specified as wikis of interest for the event.
- **Pageviews on all wikis (not just those specified): **The Main space articles counted can be on any wiki; the wikis do not need to be specified as wikis of interest in setup.
- **30-day average** To smooth out daily or weekly fluctuations, I propose we do the following:
# Looking at the most recent day available, find the articles—on all wikis—on which the images from the event have been placed,
# Get the pageview count for all those articles over the past 30 days (it's OK that not all the images will have actually //been// on all those pages during that entire period).
# Average that 30 day figure and express as a daily average.
# If page creation date is < 30 days ago, use the number of available days and average by that number.