-
Notifications
You must be signed in to change notification settings - Fork 531
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 #1624 from diox/remove-obsolete-addon-device-type
Remove obsolete AddonDeviceType model / table / constants
- Loading branch information
Showing
6 changed files
with
8 additions
and
120 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
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,49 +1,6 @@ | ||
#!/usr/bin/env python | ||
|
||
from celeryutils import task | ||
|
||
from django.core.exceptions import ObjectDoesNotExist | ||
from django.db.models import Count | ||
|
||
from olympia import amo | ||
from addons.models import AddonDeviceType as ADT | ||
from amo.decorators import write | ||
from amo.utils import chunked | ||
|
||
|
||
@task | ||
@write | ||
def _task(**kw): | ||
# Remove any dupes. `UNIQUE` constraint introduced in migration 504. | ||
dupes = (ADT.objects.values_list('addon', 'device_type') | ||
.annotate(c=Count('id')).filter(c__gt=1)) | ||
for addon, device_type, total in dupes: | ||
devices = ADT.objects.filter(addon_id=addon, device_type=device_type) | ||
for d in devices[:total - 1]: | ||
d.delete() | ||
|
||
# Remove stale device types. | ||
devices = ADT.objects.all() | ||
for chunk in chunked(devices, 50): | ||
for device in chunk: | ||
try: | ||
device.addon | ||
except ObjectDoesNotExist: | ||
device.delete() | ||
|
||
# `DEVICE_MOBILE` -> `DEVICE_MOBILE` and `DEVICE_GAIA`. | ||
devices = ADT.objects.filter(device_type=amo.DEVICE_MOBILE.id) | ||
|
||
for chunk in chunked(devices, 50): | ||
for device in chunk: | ||
if amo.DEVICE_GAIA in device.addon.device_types: | ||
continue | ||
device.id = None | ||
device.device_type = amo.DEVICE_GAIA.id | ||
device.save() | ||
device.addon.save() | ||
|
||
|
||
def run(): | ||
"""Mark mobile-compatible apps as compatible for Firefox OS as well.""" | ||
_task() | ||
# Obsolete Marketplace migration that relied on a model since removed. | ||
pass |
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,17 +1,3 @@ | ||
from olympia import amo | ||
from mkt.webapps.models import AppFeatures, Webapp | ||
|
||
|
||
def run(): | ||
"""Update feature profiles for mobile-only apps requiring qHD.""" | ||
apps = (Webapp.objects | ||
.filter(addondevicetype__device_type__in=[amo.DEVICE_MOBILE.id, | ||
amo.DEVICE_GAIA.id]) | ||
.exclude(addondevicetype__device_type__in=[amo.DEVICE_TABLET.id, | ||
amo.DEVICE_DESKTOP.id])) | ||
for app in apps: | ||
for version in app.versions.all(): | ||
af, _ = AppFeatures.objects.get_or_create(version=version) | ||
af.update(has_qhd=True) | ||
print('Marked mobile-only app "%s" (version %s) as ' | ||
'requiring a qHD device' % (app, version)) | ||
# Obsolete Marketplace migration that relied on a model since removed. | ||
pass |
1 change: 1 addition & 0 deletions
1
src/olympia/migrations/862-remove-obsolete-addon-device-type.sql
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE IF EXISTS `addons_devicetypes`; |