MetaStalk.modules.Stats.stats()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 29
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 14
nop 2
dl 0
loc 29
ccs 9
cts 9
cp 1
crap 2
rs 9.7
c 0
b 0
f 0
1
"""Creates a table figure that shows
2
 photos that did and did not have exif.
3
 """
4 1
import logging
5 1
import plotly.graph_objects as go
6
7 1
log = logging.getLogger("MetaStalk")
8
9
10 1
def stats(photos: list, invalid: list) -> go.Figure():
11
    """Stats
12
13
    Creates the table of photos showing ones with metadata and ones without
14
15
    Arguments:
16
        photos {list} -- List of photos with metadata.
17
        invalid {list} -- List of photos without metadata.
18
19
    Returns:
20
        go.Figure() -- A plotly table
21
    """
22 1
    log.info("Staring Stats")
23 1
    log.debug(
24
        "There are %s photos with metadata and %s without", len(photos), len(invalid)
25
    )
26 1
    simple_photos = []
27 1
    for i, _ in enumerate(photos):
28 1
        simple_photos.append(photos[i]["item"])
29 1
    fig = go.Figure(
30
        data=[
31
            go.Table(
32
                header=dict(values=["Photos with Metadata", "Photos without Metadata"]),
33
                cells=dict(values=[simple_photos, invalid]),
34
            )
35
        ]
36
    )
37 1
    fig.update_layout(title="Photos With and Without Metadata.", title_x=0.5)
38
    return fig
39