CulturedCheese / thesis-project

4 stars 4 forks source link

REFACTOR: alter allCountriesAllLanguages query to serve all results from a pre-aggregated table #181

Open ClimbsRocks opened 9 years ago

ClimbsRocks commented 9 years ago

the query below works within MySQL, but does not work when using db.query within node.

the workaround would be to pre-aggregate the table so that we can just serve up the entire results from the pre-aggregated table.

SELECT repository_language, countryCode, activeProgrammers FROM ( SELECT repository_language, countryCode, activeProgrammers, @country_rank := IF(@current_country = countryCode, @country_rank + 1, 1) AS country_rank, @current_country := countryCode FROM 14countries ORDER BY countryCode, activeProgrammers DESC ) ranked WHERE country_rank <= 10