ExtensionCrawler/queries/get_added_permissions.sql

54 lines
1.8 KiB
MySQL
Raw Normal View History

2017-09-02 15:45:38 +00:00
select extension_info.downloads, extension_info.extid, extension_info.name, permission, crx_most_recent_and_prev.crx_etag as updated_crx
2017-09-01 19:00:28 +00:00
from (
-- We generate a table containing every crx_etag that we crawled within the
-- last day and is an update, and a random date where we encountered the its
-- previous crx_etag. We only use it to find the crx_etag again later.
select
crx_first_date1.crx_etag,
crx_first_date1.extid,
crx_first_date1.md as most_recent_update,
2017-09-02 15:45:38 +00:00
max(crx_first_date2.md) as last_date_with_previous_version
2017-08-16 20:32:09 +00:00
from (
2017-09-01 19:00:28 +00:00
select crx_etag,extid,min(date) as md
2017-08-16 20:32:09 +00:00
from extension
2017-09-01 19:10:50 +00:00
where crx_etag is not null
2017-09-01 19:00:28 +00:00
group by crx_etag
) crx_first_date1
inner join (
select extid,min(date) as md
2017-08-16 20:32:09 +00:00
from extension
2017-09-01 19:10:50 +00:00
where crx_etag is not null
2017-09-01 19:00:28 +00:00
group by crx_etag
) crx_first_date2
on crx_first_date1.extid=crx_first_date2.extid
2017-09-02 15:45:38 +00:00
where
crx_first_date1.md>crx_first_date2.md
-- the first time we have seen the crx_etag shall be zero days in the past, rounded to days,
-- measured from the current date and hour
and
TIMESTAMPDIFF(DAY, crx_first_date1.md, TIMESTAMPADD(HOUR,HOUR(UTC_TIME),UTC_DATE)) = 0
2017-09-01 19:00:28 +00:00
group by crx_first_date1.crx_etag
) crx_most_recent_and_prev
inner join permission
on crx_most_recent_and_prev.crx_etag=permission.crx_etag
inner join extension extension_info
on crx_most_recent_and_prev.extid=extension_info.extid
and extension_info.date=most_recent_update
and extension_info.crx_etag=crx_most_recent_and_prev.crx_etag
2017-09-02 13:16:11 +00:00
where
permission in (
"<all_url>",
"http://*/*",
"https://*/*",
"webRequest",
"webRequestBlocking"
)
2017-09-02 15:45:38 +00:00
and
permission not in (
2017-09-01 19:00:28 +00:00
select permission
from extension natural join permission
2017-09-02 15:45:38 +00:00
where extid=extension_info.extid and date=last_date_with_previous_version
2017-09-01 19:10:50 +00:00
)
2017-09-02 13:16:11 +00:00
order by extension_info.downloads desc;
2017-09-01 19:10:50 +00:00