commons-app / commonsmisc

4 stars 5 forks source link

Use a single query for fetching articles using images and unique used images #4

Open maskaravivek opened 5 years ago

maskaravivek commented 5 years ago

articlesUsingImages and uniqueUsedImages are being fetched from the same table(globalimagelinks) to it can be merged into a single query.

sql = 'select count(*) as articlesUsingImages, count(distinct gil_to) as uniqueUsedImages from globalimagelinks where gil_to in (select log_title from logging_userindex where log_type="upload" and log_user=(select user_id from user where user_name="%s"));' % username

It would require merging the two methods into a single function but would at least save 1 DB call.