I hereby claim:
- I am jwhitlock on github.
- I am jwhitlock (https://keybase.io/jwhitlock) on keybase.
- I have a public key ASCM4TsGA3GcuQEIzhaDIRygGVov0DnLlcY522ujF7ZCVwo
To claim this, I am signing this object:
| #!/usr/bin/env python | |
| # Convert data from a Google Analytics export | |
| # In GA: Behavior -> Site Content -> All Pages | |
| # Adjust time range | |
| # Change Show Rows to desired content | |
| # Export -> CSV | |
| from __future__ import print_function, unicode_literals | |
| from collections import namedtuple | |
| from datetime import timedelta | |
| import csv |
| /*! | |
| * Font Awesome 4.1.0 by @davegandy - http://fontawesome.io - @fontawesome | |
| * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) | |
| */@font-face{font-family:'FontAwesome';src:url(../../styles/libs/font-awesome/fonts/fontawesome-webfont.eot?v=4.1.0);src:url(../../styles/libs/font-awesome/fonts/fontawesome-webfont.eot?#iefix&v=4.1.0) format('embedded-opentype'),url(../../styles/libs/font-awesome/fonts/fontawesome-webfont.woff?v=4.1.0) format('woff'),url(../../styles/libs/font-awesome/fonts/fontawesome-webfont.ttf?v=4.1.0) format('truetype'),url(../../styles/libs/font-awesome/fonts/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular) format('svg');font-weight:normal;font-style:normal}i[class*=" icon-"],i[class^=icon-]{display:inline-block;font-family:FontAwesome;font-style:normal;font-weight:normal;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.icon-2x{font-size:2em}.icon-3x{fo |
I hereby claim:
To claim this, I am signing this object:
| -- These have bad data in production | |
| SELECT COUNT(*) AS account_emailaddress_orphan_users FROM `account_emailaddress` WHERE NOT EXISTS (SELECT * from `auth_user` WHERE `auth_user`.`id` = `account_emailaddress`.`user_id`); | |
| SELECT * FROM `account_emailaddress` WHERE NOT EXISTS (SELECT * from `auth_user` WHERE `auth_user`.`id` = `account_emailaddress`.`user_id`); | |
| SELECT COUNT(*) AS django_admin_log_orphan_content_types FROM `django_admin_log` WHERE NOT EXISTS (SELECT * FROM `django_content_type` WHERE `django_content_type`.`id` = `django_admin_log`.`content_type_id`); | |
| SELECT * FROM `django_admin_log` WHERE NOT EXISTS (SELECT * FROM `django_content_type` WHERE `django_content_type`.`id` = `django_admin_log`.`content_type_id`); | |
| SELECT COUNT(*) AS socialaccount_socialtoken_orphan_accounts FROM `socialaccount_socialtoken` WHERE NOT EXISTS (SELECT * FROM `socialaccount_socialaccount` WHERE `socialaccount_socialaccount`.`id` = `socialaccount_socialtoken`.`account_id`); | |
| SELECT * FROM `socialaccount_socialtoken` WHERE |
| COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml |
| # Run in ./manage.py shell_plus | |
| from datetime import datetime, timedelta | |
| last_week = datetime.now() - timedelta(days=7) | |
| to_purge = Document.deleted_objects.filter(modified__lt=last_week) | |
| print("%d documents to purge" % to_purge.count()) | |
| for doc in to_purge: | |
| assert doc.deleted | |
| print("Purging document '%s'" % doc.get_full_url()) | |
| doc.purge() |
| # Run in a shell_plus session | |
| def scan_old_cts(dry_run=True): | |
| for ct in ContentType.objects.order_by('id'): | |
| if ct.model_class() is None: | |
| ct_relations(ct, dry_run) | |
| def ct_relations(ct, dry_run): | |
| relations = [ | |
| ('KeyAction', 'keyaction_set'), |
| # This works with Kuma's memcache implementation | |
| from django.core.cache import caches | |
| def clear_keys(prefix): | |
| memcache = caches['memcache'] | |
| raw_memcache = memcache._cache | |
| items = 100000 | |
| slabs = raw_memcache.get_stats('slabs') | |
| max_slabs = max([int(report[1]['active_slabs']) for report in slabs]) | |
| deleted = 0 |