-
Notifications
You must be signed in to change notification settings - Fork 16
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
User tag screening #735
User tag screening #735
Changes from 20 commits
ef7ae93
9b1df04
050ca08
34b5551
df1acc1
ef09602
008cc78
f2585d6
5a3d75d
4f30dff
728e823
4376541
b008dd2
1ec0def
789ce87
1032a60
cd62b6a
55b68d5
9e3b7e1
2a88974
73df2e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
import pandas as pd | ||
from django.apps import apps | ||
from django.contrib.postgres.aggregates import ArrayAgg | ||
from django.core.exceptions import ValidationError | ||
from django.core.validators import URLValidator | ||
from django.db import models | ||
|
@@ -351,6 +352,18 @@ def prune_tags(self, root_tag, pruned_tags, descendants: bool = False): | |
) | ||
return self.exclude(query).distinct("pk") | ||
|
||
def user_tags(self, user_id: int) -> dict[int, list[int]]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed how we're building this dictionary for the serializer since it looked like the old way required a query for each reference if user references were found |
||
# Return a dictionary of reference_id: list[tag_ids] items for all references in a queryset | ||
# TODO - update to annotate queryset with Django 4.1? | ||
# https://docs.djangoproject.com/en/4.1/ref/contrib/postgres/expressions/#arraysubquery-expressions | ||
UserReferenceTag = apps.get_model("lit", "UserReferenceTag") | ||
user_qs = ( | ||
UserReferenceTag.objects.filter(reference__in=self, user=user_id) | ||
.annotate(tag_ids=ArrayAgg("tags__id")) | ||
.values_list("reference_id", "tag_ids") | ||
) | ||
return {reference_id: tag_ids for reference_id, tag_ids in user_qs} | ||
|
||
|
||
class ReferenceManager(BaseManager): | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,7 +107,7 @@ <h3>Manually added references</h3> | |
|
||
window.app.startup("litStartup", function(lit){ | ||
let tagtree = new lit.TagTree(config.tags[0], config.assessment_id, null); | ||
tagtree.render(document.getElementById('tags')) | ||
tagtree.render(document.getElementById('tags'), {handleTagClick: (x) => {window.location.href = x.get_list_link()}}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
}); | ||
|
||
const histo = document.getElementById("referenceYearHistogram"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's nice - so it only sets a bound if it's a long abstract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that way longer abstracts aren't overwhelming on page load, but users can still expand to show the full abstract if they wish. and there's no weird oversized box with shorter abstracts