-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from ddxv/trackers-missing-app
Trackers missing app
- Loading branch information
Showing
3 changed files
with
256 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,69 @@ | ||
WITH latest_version_codes AS ( | ||
WITH my_app AS ( | ||
SELECT id | ||
FROM | ||
store_apps | ||
WHERE | ||
store_id = :store_id | ||
), | ||
|
||
latest_version_code AS ( | ||
SELECT | ||
vc.store_app, | ||
MAX(vc.version_code) AS max_version_code | ||
FROM | ||
version_codes AS vc | ||
INNER JOIN my_app AS app | ||
ON | ||
vc.store_app = app.id | ||
GROUP BY | ||
vc.store_app | ||
), | ||
|
||
company_categories AS ( | ||
SELECT | ||
c.id AS company_id, | ||
STRING_AGG( | ||
cat.name, | ||
', ' | ||
) AS category_names | ||
FROM | ||
adtech.companies AS c | ||
LEFT JOIN adtech.company_categories AS ccat | ||
ON | ||
c.id = ccat.company_id | ||
LEFT JOIN adtech.categories AS cat | ||
ON | ||
ccat.category_id = cat.id | ||
GROUP BY | ||
c.id | ||
) | ||
|
||
SELECT | ||
vd.*, | ||
vc.store_app, | ||
sa.store_id, | ||
t.name AS tracker_name, | ||
n.name AS network_name | ||
vd.xml_path, | ||
vd.tag, | ||
vd.android_name, | ||
c.name AS company_name, | ||
cc.category_names | ||
FROM | ||
version_details AS vd | ||
LEFT JOIN | ||
version_codes AS vc | ||
LEFT JOIN version_codes AS vc | ||
ON | ||
vd.version_code = vc.id | ||
LEFT JOIN network_package_map AS tm | ||
ON | ||
vd.android_name ~* tm.package_pattern::TEXT | ||
LEFT JOIN tracker_package_map AS tr | ||
ON | ||
vd.android_name ~* tr.package_pattern::TEXT | ||
LEFT JOIN trackers AS t | ||
INNER JOIN latest_version_code AS lvc | ||
ON | ||
tr.tracker = t.id | ||
LEFT JOIN networks AS n | ||
vc.version_code = lvc.max_version_code | ||
AND vc.store_app = lvc.store_app | ||
LEFT JOIN adtech.sdk_packages AS tm | ||
ON | ||
tm.network = n.id | ||
INNER JOIN | ||
latest_version_codes AS lvc | ||
vd.android_name ILIKE tm.package_pattern || '%' | ||
LEFT JOIN adtech.companies AS c | ||
ON | ||
vc.store_app = lvc.store_app | ||
AND vc.version_code = lvc.max_version_code | ||
LEFT JOIN store_apps AS sa | ||
tm.company_id = c.id | ||
LEFT JOIN company_categories AS cc | ||
ON | ||
vc.store_app = sa.id | ||
WHERE | ||
vd.android_name != '' | ||
AND | ||
sa.store_id = :store_id | ||
c.id = cc.company_id | ||
ORDER BY | ||
vc.store_app, | ||
vd.xml_path, | ||
vd.android_name | ||
vd.android_name; |
Oops, something went wrong.