Skip to content

Commit

Permalink
Merge pull request #36 from ddxv/trackers-missing-app
Browse files Browse the repository at this point in the history
Trackers missing app
  • Loading branch information
ddxv authored Feb 22, 2024
2 parents aceb3de + 06b61a9 commit 50d632f
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 231 deletions.
11 changes: 7 additions & 4 deletions backend/api_app/controllers/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ async def get_package_info(self: Self, store_id: str) -> PackageDetails:

networks = {
k: f.groupby("xml_path")["android_name"].apply(list).to_dict()
for k, f in df.groupby("network_name")
for k, f in df[
df["category_names"].str.contains("etwork", na=False)
].groupby("company_name")
}
trackers = {
k: f.groupby("xml_path")["android_name"].apply(list).to_dict()
for k, f in df.groupby("tracker_name")
for k, f in df[
df["category_names"].str.contains("racker", na=False)
].groupby("company_name")
}

is_permission = df["xml_path"] == "uses-permission"
Expand All @@ -258,8 +262,7 @@ async def get_package_info(self: Self, store_id: str) -> PackageDetails:
~is_permission
& ~is_matching_packages
& ~is_android_activity
& df["network_name"].isna()
& df["tracker_name"].isna()
& df["company_name"].isna()
]
permissions_list = permissions_df.android_name.tolist()
permissions_list = [
Expand Down
75 changes: 47 additions & 28 deletions backend/dbcon/sql/query_app_package_details.sql
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;
Loading

0 comments on commit 50d632f

Please sign in to comment.