Skip to content

Instantly share code, notes, and snippets.

@hoosteeno
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoosteeno/bb11f1b0ac8032b07ec9 to your computer and use it in GitHub Desktop.
Save hoosteeno/bb11f1b0ac8032b07ec9 to your computer and use it in GitHub Desktop.
get profile_url, url, count of revisions and bio from mdn profiles
select
url, count(wiki_revision.id) as revision_count, bio,
concat('https://developer.mozilla.org/en-US/profiles/', username) as profile_page
from
(select substring(
misc
from (
/* start substring after but not including website key */
locate('"website": ', misc) + 12
)
for (
/* the location of the first " after the website key... */
locate('"', misc, locate('"website": ', misc) + 12)
/* minus the location of the website key plus the length of the website key */
- (locate('"website": ', misc) + 12)
)
)
as url,
user_profiles.bio,
auth_user.username,
user_profiles.user_id
from user_profiles, auth_user
where user_profiles.user_id = auth_user.id
and misc is not null
and misc REGEXP '"website": '
order by auth_user.username asc)
as websites
left outer join wiki_revision on wiki_revision.creator_id = websites.user_id
group by websites.user_id
order by websites.username
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment