Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove generic relation from tags #1836

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
from messages.models import Message
from ratings.models import SoundRating
from sounds.models import DeletedSound, License, Sound, Pack, Download, PackDownload, BulkUploadProgress
from tags.models import TaggedItem
from utils.locations import locations_decorator
from utils.mail import transform_unique_email
from utils.search import get_search_engine, SearchEngineException
Expand Down
6 changes: 3 additions & 3 deletions accounts/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from accounts.views import handle_uploaded_image
from forum.models import Forum, Thread, Post
from sounds.models import Pack, Download, PackDownload
from tags.models import TaggedItem
from tags.models import SoundTag
from utils.mail import send_mail
from utils.test_helpers import override_avatars_path_with_temp_directory, create_user_and_sounds

Expand Down Expand Up @@ -67,8 +67,8 @@ def test_user_tagcloud_solr(self):
mock_search_engine.return_value.configure_mock(**conf)
accounts.models.get_search_engine = mock_search_engine
tag_names = [item['name'] for item in user.profile.get_user_tags()]
used_tag_names = list({item.tag.name for item in TaggedItem.objects.filter(user=user)})
non_used_tag_names = list({item.tag.name for item in TaggedItem.objects.exclude(user=user)})
used_tag_names = list({item.tag.name for item in SoundTag.objects.filter(user=user)})
non_used_tag_names = list({item.tag.name for item in SoundTag.objects.exclude(user=user)})

# Test that tags retrieved with get_user_tags are those found in db
self.assertEqual(len(set(tag_names).intersection(used_tag_names)), len(tag_names))
Expand Down
16 changes: 8 additions & 8 deletions monitor/management/commands/generate_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import forum.models
import ratings.models
import sounds.views
from tags.models import Tag, TaggedItem
from tags.models import Tag, SoundTag
from utils.management_commands import LoggingBaseCommand


Expand Down Expand Up @@ -120,22 +120,22 @@ def handle(self, **options):
# Compute stats related with Tags:
time_span = datetime.datetime.now()-datetime.timedelta(weeks=2)

tags_stats = TaggedItem.objects.values('tag_id')\
tags_stats = SoundTag.objects.values('tag_id')\
.filter(created__gt=time_span).annotate(num=Count('tag_id'))\
.values('num', 'tag__name').order_by('-num')[:300]

# Most used tags for tags cloud
all_tags = TaggedItem.objects.values('tag_id')\
all_tags = SoundTag.objects.values('tag_id')\
.annotate(num=Count('tag_id'))\
.values('num', 'tag__name').order_by('-num')[:300]

with connection.cursor() as cursor:
cursor.execute(\
"""SELECT count(*) as num_c, t.name, ti.tag_id as id FROM
tags_taggeditem ti, tags_tag t, sounds_download d
WHERE d.sound_id = ti.object_id AND t.id = ti.tag_id
"""SELECT count(*) as num_c, t.name, st.tag_id as id FROM
tags_soundtag st, tags_tag t, sounds_download d
WHERE d.sound_id = st.sound_id AND t.id = st.tag_id
AND d.created > current_date - interval '14 days'
GROUP BY ti.tag_id, t.name ORDER BY num_c DESC limit 300""")
GROUP BY st.tag_id, t.name ORDER BY num_c DESC limit 300""")

downloads_tags = cursor.fetchall()

Expand Down Expand Up @@ -170,7 +170,7 @@ def handle(self, **options):
num_ratings = ratings.models.SoundRating.objects.all().count()

tags = Tag.objects.all().count()
tags_used = TaggedItem.objects.all().count()
tags_used = SoundTag.objects.all().count()

posts = forum.models.Post.objects.all().count()
threads = forum.models.Thread.objects.all().count()
Expand Down
Loading
Loading