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

Performance when retrieving units #9

Open
versae opened this issue Feb 5, 2013 · 0 comments
Open

Performance when retrieving units #9

versae opened this issue Feb 5, 2013 · 0 comments

Comments

@versae
Copy link

versae commented Feb 5, 2013

When a teacher is the owner of a bunch of courses, and units of that course have a lot of videos, the REST resource of the unit becomes really slow, resulting in a poor performance of the teachersadmin interface.

One of the problems I was able to identify was the is_teacher function, as reported in another issue. But the other one was the normalize_kq_weight. Here I propose a slightly modified version, not a powerful improvement, though.

def normalize_kq_weight(kq):
    from moocng.courses.models import KnowledgeQuantum
    unit_kq_list = KnowledgeQuantum.objects.filter(unit=kq.unit).values("weight")
    total_weight = 0
    for unit_kq in unit_kq_list:
        total_weight += unit_kq["weight"]
    if total_weight == 0:
        if len(unit_kq_list) == 0:
            return 0
        else:
            return 100.0 / len(unit_kq_list)
    return (kq.weight * 100.0) / total_weight

On the other hand, I think that a different reason could be that the is_teacher function is been called with all the courses instead of being called just with the course related to the unit. I'm not 100% sure, but please, take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant