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

iplweb / bpp / 18634744198

19 Oct 2025 07:00PM UTC coverage: 31.618% (-29.9%) from 61.514%
18634744198

push

github

mpasternak
Merge branch 'release/v202510.1270'

657 of 9430 branches covered (6.97%)

Branch coverage included in aggregate %.

229 of 523 new or added lines in 42 files covered. (43.79%)

11303 existing lines in 316 files now uncovered.

14765 of 39346 relevant lines covered (37.53%)

0.38 hits per line

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

17.78
src/bpp/tasks.py
1
import os
1✔
2

3
from celery.utils.log import get_task_logger
1✔
4
from django.conf import settings
1✔
5
from django.core.exceptions import ImproperlyConfigured
1✔
6

7
try:
1✔
8
    pass
1✔
9
except ImportError:
×
10
    pass
×
11

12
from bpp.models import (
1✔
13
    Praca_Doktorska,
14
    Praca_Habilitacyjna,
15
    Uczelnia,
16
    Wydawnictwo_Ciagle,
17
    Wydawnictwo_Zwarte,
18
)
19

20
logger = get_task_logger(__name__)
1✔
21

22
from django_bpp.celery_tasks import app
1✔
23

24

25
@app.task(ignore_result=True)
1✔
26
def remove_file(path):
1✔
27
    if path.startswith(os.path.join(settings.MEDIA_ROOT, "report")):
×
28
        logger.warning("Removing %r" % path)
×
29
        os.unlink(path)
×
30

31

32
task_limits = {}
1✔
33

34

35
def my_limit(fun):
1✔
36
    res = task_limits.get(fun)
×
37
    if not res or (res.successful() or res.failed()):
×
38
        task_limits[fun] = fun.apply_async(
×
39
            countdown=settings.MAT_VIEW_REFRESH_COUNTDOWN
40
        )
41
        return
×
42

43
    if res:
×
44
        logger.info("Task %r has been revoked." % res.id)
×
45
        res.revoke()
×
46
        task_limits[fun] = fun.apply_async(
×
47
            countdown=settings.MAT_VIEW_REFRESH_COUNTDOWN
48
        )
49

50

51
def _zaktualizuj_liczbe_cytowan(klasy=None):
1✔
UNCOV
52
    if klasy is None:
×
53
        klasy = (
×
54
            Wydawnictwo_Ciagle,
55
            Wydawnictwo_Zwarte,
56
            Praca_Doktorska,
57
            Praca_Habilitacyjna,
58
        )
59

UNCOV
60
    for uczelnia in Uczelnia.objects.all():
×
UNCOV
61
        try:
×
UNCOV
62
            client = uczelnia.wosclient()
×
63
        except ImproperlyConfigured:
×
64
            continue
×
65

66
        # FIXME: jeżeli jest >1 uczelnia w systemie, to odpytanie
67
        # obiektów nastąpi w sposób wielokrotny...
68

UNCOV
69
        for klass in klasy:
×
UNCOV
70
            filtered = (
×
71
                klass.objects.all()
72
                .exclude(doi=None)
73
                .exclude(pubmed_id=None)
74
                .values("id", "doi", "pubmed_id")
75
            )
76

UNCOV
77
            for grp in client.query_multiple(filtered):
×
UNCOV
78
                for k, item in grp.items():
×
UNCOV
79
                    changed = False
×
80

UNCOV
81
                    timesCited = item.get("timesCited")
×
UNCOV
82
                    doi = item.get("doi")
×
UNCOV
83
                    pubmed_id = item.get("pmid")
×
84

UNCOV
85
                    obj = klass.objects.get(pk=k)
×
86

UNCOV
87
                    if timesCited is not None:
×
UNCOV
88
                        if obj.liczba_cytowan != timesCited:
×
UNCOV
89
                            obj.liczba_cytowan = timesCited
×
UNCOV
90
                            changed = True
×
91

UNCOV
92
                    if pubmed_id is not None:
×
93
                        if obj.pubmed_id != pubmed_id:
×
94
                            obj.pubmed_id = pubmed_id
×
95
                            changed = True
×
96

UNCOV
97
                    if doi is not None:
×
98
                        if obj.doi != doi:
×
99
                            obj.doi = doi
×
100
                            changed = True
×
101

UNCOV
102
                    if changed:
×
UNCOV
103
                        obj.save()
×
104

105

106
@app.task
1✔
107
def zaktualizuj_liczbe_cytowan():
1✔
108
    _zaktualizuj_liczbe_cytowan()
×
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