GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

crowdtruth.models.worker.Worker.aggregate()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 30
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 30
ccs 7
cts 7
cp 1
rs 9.8
c 0
b 0
f 0
cc 2
nop 2
crap 2
1
"""
2
Worker initialization.
3
"""
4 1
class Worker():
5
    """
6
    Performs general statistics over the workers in the jobs.
7
    """
8
9 1
    @staticmethod
10
    def aggregate(judgments, config):
11
        """
12
        Aggregates information for each worker about the total number of jobs and units
13
        (s)he contributed to, the total number of judgments submitted, the total
14
        amount of time spent of annotating and the average number of annotations provided
15
        across all the units.
16
17
        Args:
18
            judgments: Judgments contained in the job.
19
            config: Job configuration as provided as input for the metrics.
20
21
        Returns:
22
            A dataframe containing all workers that contributed to the jobs and the
23
            statistics relevant for them.
24
        """
25 1
        workers = judgments.copy().groupby('worker')
26
27 1
        agg = {
28
            'job' : 'nunique',
29
            'unit' : 'nunique',
30
            'judgment' : 'nunique',
31
            'duration' : 'mean'
32
            }
33 1
        for col in config.output.values():
34 1
            agg[col+'.count'] = 'mean'
35
36 1
        workers = workers.agg(agg)
37
38
        return workers
39