def test_simple(self, mock_sync_integration_docs): responses.add("GET", "https://docs.getsentry.com/hosted/_platforms/_index.json", body=INDEX_JSON) sync_docs() data = options.get("sentry:docs") assert data == { "platforms": [ { "id": "go", "integrations": [ { "id": "go", "link": "https://docs.getsentry.com/hosted/clients/go/", "name": "Go", "type": "language", }, {"id": "go-http", "link": None, "name": "net/http", "type": "framework"}, ], "name": "Go", } ] } assert mock_sync_integration_docs.mock_calls == [ mock.call.delay("go", "_self", "go.json"), mock.call.delay("go", "http", "go/http.json"), ]
def repair(): "Attempt to repair any invalid data." click.echo('Forcing documentation sync') from sentry.tasks.sync_docs import sync_docs sync_docs() from sentry.models import Activity, Project, ProjectKey click.echo('Creating missing project keys') queryset = Project.objects.filter(key_set__isnull=True) for project in queryset: try: ProjectKey.objects.get_or_create( project=project, ) except ProjectKey.MultipleObjectsReturned: pass from django.db import connection click.echo("Correcting Group.num_comments counter") cursor = connection.cursor() cursor.execute(""" UPDATE sentry_groupedmessage SET num_comments = ( SELECT COUNT(*) from sentry_activity WHERE type = %s and group_id = sentry_groupedmessage.id ) """, [Activity.NOTE])
def test_simple(self, mock_sync_integration_docs): responses.add( 'GET', 'https://docs.getsentry.com/hosted/_platforms/_index.json', body=INDEX_JSON) sync_docs() data = options.get('sentry:docs') assert data == { 'platforms': [{ 'id': 'go', 'integrations': [{ 'id': 'go', 'link': 'https://docs.getsentry.com/hosted/clients/go/', 'name': 'Go', 'type': 'language' }, { 'id': 'go-http', 'link': None, 'name': 'net/http', 'type': 'framework' }], 'name': 'Go', }] } assert mock_sync_integration_docs.mock_calls == [ mock.call.delay('go', '_self', 'go.json'), mock.call.delay('go', 'http', 'go/http.json'), ]
def handle(self, **options): print("Forcing documentation sync") from sentry.tasks.sync_docs import sync_docs sync_docs() from sentry.models import Project, ProjectKey print("Creating missing project keys") queryset = Project.objects.filter(key_set__isnull=True) for project in queryset: try: ProjectKey.objects.get_or_create( project=project, ) except ProjectKey.MultipleObjectsReturned: pass
def handle(self, **options): print("Forcing documentation sync") from sentry.tasks.sync_docs import sync_docs sync_docs() from sentry.models import Project, ProjectKey print("Creating missing project keys") queryset = Project.objects.filter(key_set__isnull=True) for project in queryset: try: ProjectKey.objects.get_or_create(project=project) except ProjectKey.MultipleObjectsReturned: pass
def handle(self, **options): print("Forcing documentation sync") from sentry.tasks.sync_docs import sync_docs sync_docs() from sentry.models import Activity, Project, ProjectKey print("Creating missing project keys") queryset = Project.objects.filter(key_set__isnull=True) for project in queryset: try: ProjectKey.objects.get_or_create(project=project, ) except ProjectKey.MultipleObjectsReturned: pass print("Correcting Group.num_comments counter") cursor = connection.cursor() cursor.execute( """ UPDATE sentry_groupedmessage SET num_comments = ( SELECT COUNT(*) from sentry_activity WHERE type = %s and group_id = sentry_groupedmessage.id ) """, [Activity.NOTE])