# Path: app/models.py
# class RepoStarring(models.Model):
#     user_id = models.IntegerField()
#     user_username = models.CharField(max_length=39)
#     repo_id = models.IntegerField()
#     repo_full_name = models.CharField(max_length=140)
#     starred_at = models.DateTimeField()
# 
#     class Meta:
#         unique_together = (('user_id', 'repo_id'),)
# 
#     def __str__(self):
#         return '@{0} starred {1}'.format(self.user_username, self.repo_full_name)
# 
#     @staticmethod
#     def create_one(user_dict, repo_dict):
#         rs = RepoStarring()
#         try:
#             rs.user_id = user_dict['id']
#             rs.user_username = user_dict['login']
#             rs.repo_id = repo_dict['id']
#             rs.repo_full_name = repo_dict['full_name']
#             rs.starred_at = repo_dict['starred_at']
#         except (KeyError, TypeError) as e:
#             print(e)
#             print(user_dict)
#             print(repo_dict)
#             return
# 
#         try:
#             rs.save()
#         except IntegrityError:
#             pass
# 
# Path: app/models.py
# class UserRelation(models.Model):
#     from_user_id = models.IntegerField()
#     from_username = models.CharField(max_length=39)
#     to_user_id = models.IntegerField()
#     to_username = models.CharField(max_length=39)
#     relation = models.CharField(max_length=16)
# 
#     class Meta:
#         unique_together = (('from_user_id', 'relation', 'to_user_id'),)
# 
#     def __str__(self):
#         return '@{0} {1} @{2}'.format(self.from_username, self.relation, self.to_username)
# 
#     @staticmethod
#     def create_one(from_user, relation, to_user):
#         ur = UserRelation()
#         try:
#             ur.from_user_id = from_user['id']
#             ur.from_username = from_user['login']
#             ur.relation = relation
#             ur.to_user_id = to_user['id']
#             ur.to_username = to_user['login']
#         except (KeyError, TypeError) as e:
#             print(e)
#             print(from_user)
#             print(to_user)
#             return
# 
#         try:
#             ur.save()
#         except IntegrityError:
#             pass


from django.core.management.base import BaseCommand
from app.models import RepoStarring
from app.models import UserRelation
# coding: utf-8




class Command(BaseCommand):

    def handle(self, *args, **options):
        UserRelation.objects.all().delete()

# Path: app/models.py
# class RepoStarring(models.Model):
#     user_id = models.IntegerField()
#     user_username = models.CharField(max_length=39)
#     repo_id = models.IntegerField()
#     repo_full_name = models.CharField(max_length=140)
#     starred_at = models.DateTimeField()
# 
#     class Meta:
#         unique_together = (('user_id', 'repo_id'),)
# 
#     def __str__(self):
#         return '@{0} starred {1}'.format(self.user_username, self.repo_full_name)
# 
#     @staticmethod
#     def create_one(user_dict, repo_dict):
#         rs = RepoStarring()
#         try:
#             rs.user_id = user_dict['id']
#             rs.user_username = user_dict['login']
#             rs.repo_id = repo_dict['id']
#             rs.repo_full_name = repo_dict['full_name']
#             rs.starred_at = repo_dict['starred_at']
#         except (KeyError, TypeError) as e:
#             print(e)
#             print(user_dict)
#             print(repo_dict)
#             return
# 
#         try:
#             rs.save()
#         except IntegrityError:
#             pass
# 
# Path: app/models.py
# class UserRelation(models.Model):
#     from_user_id = models.IntegerField()
#     from_username = models.CharField(max_length=39)
#     to_user_id = models.IntegerField()
#     to_username = models.CharField(max_length=39)
#     relation = models.CharField(max_length=16)
# 
#     class Meta:
#         unique_together = (('from_user_id', 'relation', 'to_user_id'),)
# 
#     def __str__(self):
#         return '@{0} {1} @{2}'.format(self.from_username, self.relation, self.to_username)
# 
#     @staticmethod
#     def create_one(from_user, relation, to_user):
#         ur = UserRelation()
#         try:
#             ur.from_user_id = from_user['id']
#             ur.from_username = from_user['login']
#             ur.relation = relation
#             ur.to_user_id = to_user['id']
#             ur.to_username = to_user['login']
#         except (KeyError, TypeError) as e:
#             print(e)
#             print(from_user)
#             print(to_user)
#             return
# 
#         try:
#             ur.save()
#         except IntegrityError:
#             pass


# Path: app/management/commands/drop_data.py
from django.core.management.base import BaseCommand
from app.models import RepoStarring
from app.models import UserRelation

# coding: utf-8




class Command(BaseCommand):

    def handle(self, *args, **options):
        UserRelation.objects.all().delete()

        RepoStarring.objects.all().delete()