I have a set of projects that themselves are associated with deployments. A project can…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
I have a set of projects that themselves are associated with deployments. A project can be deployed multiple times.
How can I compute "trending" projects, defined as projects that are growing fast in number of deployments, regardless of whether they get LOTS of deployments or not. In other words, a trending project could be a project that goes from 10 deployments a day to 100 deployments a day overnight, as well as a project that goes from 200000 deployments a day to 300000.
Use SQL
- Assistant
You can use SQL to compute trending projects by grouping the projects by their deployment date, and then calculating the difference in the number of deployments between each group. Here is an example SQL query that demonstrates this:
codeWITH project_deployments AS ( SELECT project_id, deployment_date, COUNT(*) AS deployments FROM deployments GROUP BY project_id, deployment_date ) SELECT project_id, deployment_date, deployments, LAG(deployments, 1) OVER (PARTITION BY project_id ORDER BY deployment_date) - deployments AS deployment_change FROM project_deployments ORDER BY deployment_change DESC;This query uses a common table expression (CTE) to group the deployments by project and deployment date, and then calculates the difference in deployments between each date using the LAG window function. It then orders the results by the deployment change, so that the projects with the largest increases in deployments are at the top of the list.
You may want to filter the date range or to average over a week or a month to get more meaningful results.