• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uw-it-aca / pathways / 17604285327

10 Sep 2025 05:35AM UTC coverage: 93.644% (-4.2%) from 97.822%
17604285327

Pull #291

github

web-flow
Merge 80aa05cf1 into 251bd9fb5
Pull Request #291: update data files, add stats generator for validation

0 of 42 new or added lines in 1 file covered. (0.0%)

943 of 1007 relevant lines covered (93.64%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pathways/management/commands/validate_data.py
1
# Copyright 2025 UW-IT, University of Washington
2
# SPDX-License-Identifier: Apache-2.0
3

NEW
4
from django.core.management.base import BaseCommand
×
NEW
5
from pathways.models.major import Major, SimilarMajor
×
NEW
6
from pathways.models.course import Course
×
NEW
7
from multiprocessing import Pool, cpu_count
×
8

9

NEW
10
class Command(BaseCommand):
×
11

NEW
12
    def handle(self, *args, **options):
×
NEW
13
        self.validate_majors()
×
NEW
14
        self.validate_courses()
×
15

NEW
16
    def validate_majors(self)   :
×
NEW
17
        count_majors = Major.objects.count()
×
NEW
18
        count_gpa_2yr = (Major.objects.filter(gpa_2yr__isnull=False)
×
19
                            .count())
NEW
20
        count_gpa_5yr = (Major.objects.filter(gpa_5yr__isnull=False)
×
21
                            .count())
NEW
22
        count_common_courses = 0
×
NEW
23
        for major in Major.objects.all():
×
NEW
24
            cc = major.get_common_with_coi_and_flags()
×
NEW
25
            if cc and len(cc) > 0:
×
NEW
26
                count_common_courses += 1
×
27
        # count of distinct source_major in SimilarMajor
NEW
28
        count_similar_majors = SimilarMajor.objects.values('source_major')\
×
29
            .distinct().count()
NEW
30
        print(f"Total Majors: {count_majors}")
×
NEW
31
        print(f"Majors with GPA Distro (2, 5): {count_gpa_2yr} "
×
32
              f"({(count_gpa_2yr/count_majors)*100:.2f}%, "
33
              f"{count_gpa_5yr} ({(count_gpa_5yr/count_majors)*100:.2f}%)")
NEW
34
        print(f"Majors with Common Courses: {count_common_courses}"
×
35
              f" ({(count_common_courses/count_majors)*100:.2f}%)")
NEW
36
        print(f"Majors with Similar Majors: {count_similar_majors} "
×
37
              f"({(count_similar_majors/count_majors)*100:.2f}%)")
38

NEW
39
    def validate_courses(self):
×
NEW
40
        count_courses = Course.objects.count()
×
NEW
41
        print(count_courses)
×
NEW
42
        count_with_grade_distro = \
×
43
            (Course.objects.filter(gpa_distro__isnull=False).count())
NEW
44
        count_with_prereq = (Course.objects.filter(prereq_graph__isnull=False))
×
45

NEW
46
        pool = Pool(processes=cpu_count()-1)
×
NEW
47
        results = pool.map(self._process_course, Course.objects.all())
×
NEW
48
        pool.close()
×
NEW
49
        pool.join()
×
NEW
50
        count_with_coi = len([r for r in results if r[1]])
×
NEW
51
        count_with_concurrent = len([r for r in results if r[2]])
×
52

NEW
53
        print(f"Total Courses: {count_courses}")
×
NEW
54
        print(f"Courses with Grade Distro: {count_with_grade_distro}"
×
55
              f" ({(count_with_grade_distro/count_courses)*100:.2f}%)")
NEW
56
        print(f"Courses with Prereq Map: {count_with_prereq.count()}"
×
57
              f" ({(count_with_prereq.count()/count_courses)*100:.2f}%)")
NEW
58
        print(f"Courses with COI: {count_with_coi}"
×
59
              f" ({(count_with_coi/count_courses)*100:.2f}%)")
NEW
60
        print(f"Courses with Concurrent: {count_with_concurrent}"
×
61
              f" ({(count_with_concurrent/count_courses)*100:.2f}%)")
62

63

NEW
64
    @staticmethod
×
NEW
65
    def _process_course(course):
×
NEW
66
        coi = course.get_coi_data()
×
NEW
67
        concurrent = course.get_concurrent_with_coi_and_flags()
×
68
        return (course.course_id, bool(coi), bool(concurrent))
×
69

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc