geo-activity-playground 0.24.1__py3-none-any.whl → 0.24.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geo_activity_playground/webui/equipment/controller.py +80 -39
- geo_activity_playground/webui/equipment/templates/equipment/index.html.j2 +14 -3
- geo_activity_playground/webui/summary/controller.py +11 -8
- {geo_activity_playground-0.24.1.dist-info → geo_activity_playground-0.24.2.dist-info}/METADATA +1 -1
- {geo_activity_playground-0.24.1.dist-info → geo_activity_playground-0.24.2.dist-info}/RECORD +8 -8
- {geo_activity_playground-0.24.1.dist-info → geo_activity_playground-0.24.2.dist-info}/LICENSE +0 -0
- {geo_activity_playground-0.24.1.dist-info → geo_activity_playground-0.24.2.dist-info}/WHEEL +0 -0
- {geo_activity_playground-0.24.1.dist-info → geo_activity_playground-0.24.2.dist-info}/entry_points.txt +0 -0
| @@ -10,64 +10,105 @@ class EquipmentController: | |
| 10 10 | 
             
                    self._repository = repository
         | 
| 11 11 |  | 
| 12 12 | 
             
                def render(self) -> dict:
         | 
| 13 | 
            -
                     | 
| 14 | 
            -
                         | 
| 15 | 
            -
                        .apply(
         | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
                                    "time": group["start"],
         | 
| 19 | 
            -
                                    "total_distance_km": group["distance_km"].cumsum(),
         | 
| 20 | 
            -
                                }
         | 
| 21 | 
            -
                            ),
         | 
| 22 | 
            -
                            include_groups=False,
         | 
| 23 | 
            -
                        )
         | 
| 24 | 
            -
                        .reset_index()
         | 
| 25 | 
            -
                    )
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                    plot = (
         | 
| 28 | 
            -
                        alt.Chart(
         | 
| 29 | 
            -
                            total_distances,
         | 
| 30 | 
            -
                            height=250,
         | 
| 31 | 
            -
                            width=250,
         | 
| 32 | 
            -
                            title="Equipment Usage over Time",
         | 
| 33 | 
            -
                        )
         | 
| 34 | 
            -
                        .mark_line(interpolate="step-after")
         | 
| 35 | 
            -
                        .encode(
         | 
| 36 | 
            -
                            alt.X("time", title="Date"),
         | 
| 37 | 
            -
                            alt.Y("total_distance_km", title="Cumulative distance / km"),
         | 
| 38 | 
            -
                        )
         | 
| 39 | 
            -
                        .facet("equipment", columns=4, title="Equipment")
         | 
| 40 | 
            -
                        .resolve_scale(y="independent")
         | 
| 41 | 
            -
                        .resolve_axis(x="independent")
         | 
| 42 | 
            -
                        .interactive()
         | 
| 43 | 
            -
                        .to_json(format="vega")
         | 
| 13 | 
            +
                    kind_per_equipment = self._repository.meta.groupby("equipment").apply(
         | 
| 14 | 
            +
                        lambda group: group.groupby("kind")
         | 
| 15 | 
            +
                        .apply(lambda group2: sum(group2["distance_km"]), include_groups=False)
         | 
| 16 | 
            +
                        .idxmax(),
         | 
| 17 | 
            +
                        include_groups=False,
         | 
| 44 18 | 
             
                    )
         | 
| 45 19 |  | 
| 46 20 | 
             
                    equipment_summary = (
         | 
| 47 21 | 
             
                        self._repository.meta.groupby("equipment")
         | 
| 48 22 | 
             
                        .apply(
         | 
| 49 | 
            -
                            lambda group: pd. | 
| 23 | 
            +
                            lambda group: pd.Series(
         | 
| 50 24 | 
             
                                {
         | 
| 51 25 | 
             
                                    "total_distance_km": group["distance_km"].sum(),
         | 
| 52 26 | 
             
                                    "first_use": group["start"].iloc[0],
         | 
| 53 27 | 
             
                                    "last_use": group["start"].iloc[-1],
         | 
| 54 28 | 
             
                                },
         | 
| 55 | 
            -
                                index=[0],
         | 
| 56 29 | 
             
                            ),
         | 
| 57 30 | 
             
                            include_groups=False,
         | 
| 58 31 | 
             
                        )
         | 
| 59 | 
            -
                        .reset_index()
         | 
| 60 32 | 
             
                        .sort_values("last_use", ascending=False)
         | 
| 61 33 | 
             
                    )
         | 
| 62 34 |  | 
| 35 | 
            +
                    equipment_summary["primarily_used_for"] = None
         | 
| 36 | 
            +
                    for equipment, kind in kind_per_equipment.items():
         | 
| 37 | 
            +
                        equipment_summary.loc[equipment, "primarily_used_for"] = kind
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    equipment_variables = {}
         | 
| 40 | 
            +
                    for equipment in equipment_summary.index:
         | 
| 41 | 
            +
                        selection = self._repository.meta.loc[
         | 
| 42 | 
            +
                            self._repository.meta["equipment"] == equipment
         | 
| 43 | 
            +
                        ]
         | 
| 44 | 
            +
                        total_distances = pd.DataFrame(
         | 
| 45 | 
            +
                            {
         | 
| 46 | 
            +
                                "time": selection["start"],
         | 
| 47 | 
            +
                                "total_distance_km": selection["distance_km"].cumsum(),
         | 
| 48 | 
            +
                            }
         | 
| 49 | 
            +
                        )
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                        total_distances_plot = (
         | 
| 52 | 
            +
                            alt.Chart(
         | 
| 53 | 
            +
                                total_distances,
         | 
| 54 | 
            +
                                height=300,
         | 
| 55 | 
            +
                                width=300,
         | 
| 56 | 
            +
                                title="Usage over Time",
         | 
| 57 | 
            +
                            )
         | 
| 58 | 
            +
                            .mark_line(interpolate="step-after")
         | 
| 59 | 
            +
                            .encode(
         | 
| 60 | 
            +
                                alt.X("time", title="Date"),
         | 
| 61 | 
            +
                                alt.Y("total_distance_km", title="Cumulative distance / km"),
         | 
| 62 | 
            +
                            )
         | 
| 63 | 
            +
                            .interactive()
         | 
| 64 | 
            +
                            .to_json(format="vega")
         | 
| 65 | 
            +
                        )
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                        yearly_distance_plot = (
         | 
| 68 | 
            +
                            alt.Chart(
         | 
| 69 | 
            +
                                selection,
         | 
| 70 | 
            +
                                height=300,
         | 
| 71 | 
            +
                                title="Yearly distance",
         | 
| 72 | 
            +
                            )
         | 
| 73 | 
            +
                            .mark_bar()
         | 
| 74 | 
            +
                            .encode(
         | 
| 75 | 
            +
                                alt.X("year(start):O", title="Year"),
         | 
| 76 | 
            +
                                alt.Y("sum(distance_km)", title="Distance / km"),
         | 
| 77 | 
            +
                            )
         | 
| 78 | 
            +
                            .to_json(format="vega")
         | 
| 79 | 
            +
                        )
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                        usages_plot = (
         | 
| 82 | 
            +
                            alt.Chart(
         | 
| 83 | 
            +
                                selection,
         | 
| 84 | 
            +
                                height=300,
         | 
| 85 | 
            +
                                title="Kinds",
         | 
| 86 | 
            +
                            )
         | 
| 87 | 
            +
                            .mark_bar()
         | 
| 88 | 
            +
                            .encode(
         | 
| 89 | 
            +
                                alt.X("kind", title="Year"),
         | 
| 90 | 
            +
                                alt.Y("sum(distance_km)", title="Distance / km"),
         | 
| 91 | 
            +
                            )
         | 
| 92 | 
            +
                            .to_json(format="vega")
         | 
| 93 | 
            +
                        )
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                        equipment_variables[equipment] = {
         | 
| 96 | 
            +
                            "total_distances_plot": total_distances_plot,
         | 
| 97 | 
            +
                            "total_distances_plot_id": f"total_distances_plot_{hash(equipment)}",
         | 
| 98 | 
            +
                            "yearly_distance_plot": yearly_distance_plot,
         | 
| 99 | 
            +
                            "yearly_distance_plot_id": f"yearly_distance_plot_{hash(equipment)}",
         | 
| 100 | 
            +
                            "usages_plot": usages_plot,
         | 
| 101 | 
            +
                            "usages_plot_id": f"usages_plot_{hash(equipment)}",
         | 
| 102 | 
            +
                        }
         | 
| 103 | 
            +
             | 
| 63 104 | 
             
                    config = get_config()
         | 
| 64 105 | 
             
                    if "offsets" in config:
         | 
| 65 106 | 
             
                        for equipment, offset in config["offsets"].items():
         | 
| 66 | 
            -
                            equipment_summary.loc[
         | 
| 67 | 
            -
                                equipment_summary["equipment"] == equipment, "total_distance_km"
         | 
| 68 | 
            -
                            ] += offset
         | 
| 107 | 
            +
                            equipment_summary.loc[equipment, "total_distance_km"] += offset
         | 
| 69 108 |  | 
| 70 109 | 
             
                    return {
         | 
| 71 | 
            -
                        " | 
| 72 | 
            -
                        "equipment_summary": equipment_summary.to_dict( | 
| 110 | 
            +
                        "equipment_variables": equipment_variables,
         | 
| 111 | 
            +
                        "equipment_summary": equipment_summary.reset_index().to_dict(
         | 
| 112 | 
            +
                            orient="records"
         | 
| 113 | 
            +
                        ),
         | 
| 73 114 | 
             
                    }
         | 
| @@ -13,6 +13,7 @@ | |
| 13 13 | 
             
                        <thead>
         | 
| 14 14 | 
             
                            <tr>
         | 
| 15 15 | 
             
                                <th>Equipment</th>
         | 
| 16 | 
            +
                                <th>Primarily used for</th>
         | 
| 16 17 | 
             
                                <th style="text-align: right;">Distance / km</th>
         | 
| 17 18 | 
             
                                <th style="text-align: right;">First use</th>
         | 
| 18 19 | 
             
                                <th style="text-align: right;">Last use</th>
         | 
| @@ -22,6 +23,7 @@ | |
| 22 23 | 
             
                            {% for equipment in equipment_summary %}
         | 
| 23 24 | 
             
                            <tr>
         | 
| 24 25 | 
             
                                <td>{{ equipment.equipment }}</td>
         | 
| 26 | 
            +
                                <td>{{ equipment.primarily_used_for }}</td>
         | 
| 25 27 | 
             
                                <td style="text-align: right;">{{ equipment.total_distance_km|int }}</td>
         | 
| 26 28 | 
             
                                <td style="text-align: right;">{{ equipment.first_use.date() }}</td>
         | 
| 27 29 | 
             
                                <td style="text-align: right;">{{ equipment.last_use.date() }}</td>
         | 
| @@ -34,13 +36,22 @@ | |
| 34 36 |  | 
| 35 37 | 
             
            <div class="row mb-3">
         | 
| 36 38 | 
             
                <div class="col">
         | 
| 37 | 
            -
                    <h2> | 
| 39 | 
            +
                    <h2>Details for each equipment</h2>
         | 
| 38 40 | 
             
                </div>
         | 
| 39 41 | 
             
            </div>
         | 
| 40 42 |  | 
| 43 | 
            +
            {% for equipment, data in equipment_variables.items() %}
         | 
| 44 | 
            +
            <h3>{{ equipment }}</h3>
         | 
| 41 45 | 
             
            <div class="row mb-3">
         | 
| 42 | 
            -
                <div class="col">
         | 
| 43 | 
            -
                    {{ vega_direct( | 
| 46 | 
            +
                <div class="col-md-4">
         | 
| 47 | 
            +
                    {{ vega_direct(data.total_distances_plot_id, data.total_distances_plot) }}
         | 
| 48 | 
            +
                </div>
         | 
| 49 | 
            +
                <div class="col-md-4">
         | 
| 50 | 
            +
                    {{ vega_direct(data.yearly_distance_plot_id, data.yearly_distance_plot) }}
         | 
| 51 | 
            +
                </div>
         | 
| 52 | 
            +
                <div class="col-md-4">
         | 
| 53 | 
            +
                    {{ vega_direct(data.usages_plot_id, data.usages_plot) }}
         | 
| 44 54 | 
             
                </div>
         | 
| 45 55 | 
             
            </div>
         | 
| 56 | 
            +
            {% endfor %}
         | 
| 46 57 | 
             
            {% endblock %}
         | 
| @@ -61,11 +61,13 @@ def nominate_activities(meta: pd.DataFrame) -> dict[int, list[str]]: | |
| 61 61 | 
             
                i = subset["elapsed_time"].idxmax()
         | 
| 62 62 | 
             
                nominations[i].append(f"Longest elapsed time: {meta.loc[i].elapsed_time}")
         | 
| 63 63 |  | 
| 64 | 
            -
                 | 
| 65 | 
            -
             | 
| 64 | 
            +
                if "calories" in subset.columns:
         | 
| 65 | 
            +
                    i = subset["calories"].idxmax()
         | 
| 66 | 
            +
                    nominations[i].append(f"Most calories burnt: {meta.loc[i].calories:.0f} kcal")
         | 
| 66 67 |  | 
| 67 | 
            -
                 | 
| 68 | 
            -
             | 
| 68 | 
            +
                if "steps" in subset:
         | 
| 69 | 
            +
                    i = subset["steps"].idxmax()
         | 
| 70 | 
            +
                    nominations[i].append(f"Most steps: {meta.loc[i].steps:.0f}")
         | 
| 69 71 |  | 
| 70 72 | 
             
                for kind, group in meta.groupby("kind"):
         | 
| 71 73 | 
             
                    for key, text in [
         | 
| @@ -83,10 +85,11 @@ def nominate_activities(meta: pd.DataFrame) -> dict[int, list[str]]: | |
| 83 85 | 
             
                        ),
         | 
| 84 86 | 
             
                        ("steps", lambda row: f"Most steps for {row.kind}: {row.steps:.0f}"),
         | 
| 85 87 | 
             
                    ]:
         | 
| 86 | 
            -
                         | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
                             | 
| 88 | 
            +
                        if key in group.columns:
         | 
| 89 | 
            +
                            series = group[key]
         | 
| 90 | 
            +
                            i = series.idxmax()
         | 
| 91 | 
            +
                            if not pd.isna(i):
         | 
| 92 | 
            +
                                nominations[i].append(text(meta.loc[i]))
         | 
| 90 93 |  | 
| 91 94 | 
             
                return nominations
         | 
| 92 95 |  | 
    
        {geo_activity_playground-0.24.1.dist-info → geo_activity_playground-0.24.2.dist-info}/RECORD
    RENAMED
    
    | @@ -46,8 +46,8 @@ geo_activity_playground/webui/eddington/templates/eddington/index.html.j2,sha256 | |
| 46 46 | 
             
            geo_activity_playground/webui/entry_controller.py,sha256=v8twD3LJ0SoVtvzJoDKnU8dTtMZAKvhNU2AEH2Z87OA,1886
         | 
| 47 47 | 
             
            geo_activity_playground/webui/equipment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         | 
| 48 48 | 
             
            geo_activity_playground/webui/equipment/blueprint.py,sha256=YbOAsjk05BMeUlD6wGfxE1amvlLsFjG4HMJn5SBrVRU,551
         | 
| 49 | 
            -
            geo_activity_playground/webui/equipment/controller.py,sha256= | 
| 50 | 
            -
            geo_activity_playground/webui/equipment/templates/equipment/index.html.j2,sha256= | 
| 49 | 
            +
            geo_activity_playground/webui/equipment/controller.py,sha256=m1LNaGCNJnW97TlKT6x9NfQcMp6RKcZ8Q0I1FTUAvss,4037
         | 
| 50 | 
            +
            geo_activity_playground/webui/equipment/templates/equipment/index.html.j2,sha256=FEfxB4XwVYELAOdjVlSlprjJH_kLmE-pNWEEXdPqc6I,1778
         | 
| 51 51 | 
             
            geo_activity_playground/webui/explorer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         | 
| 52 52 | 
             
            geo_activity_playground/webui/explorer/blueprint.py,sha256=jHE6bb4H2GmYaix9P452Cyrn_30z_Nm705AZ0WNm4HQ,1950
         | 
| 53 53 | 
             
            geo_activity_playground/webui/explorer/controller.py,sha256=8d0FFrG55ZlPQ5seQC2DegxIkPGIW7pvw8Jm4eJt3fg,10634
         | 
| @@ -75,7 +75,7 @@ geo_activity_playground/webui/static/site.webmanifest,sha256=4vYxdPMpwTdB8EmOvHk | |
| 75 75 | 
             
            geo_activity_playground/webui/strava_controller.py,sha256=-DZ1Ae-0cWx5tia2dJpGfsBBoIya0QO7IC2qa1-7Q_U,779
         | 
| 76 76 | 
             
            geo_activity_playground/webui/summary/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         | 
| 77 77 | 
             
            geo_activity_playground/webui/summary/blueprint.py,sha256=kzQ6MDOycQKfDcVoEUmL7HYHJA_gu8DlzVHwO37-_jA,514
         | 
| 78 | 
            -
            geo_activity_playground/webui/summary/controller.py,sha256= | 
| 78 | 
            +
            geo_activity_playground/webui/summary/controller.py,sha256=i6A9-S9j9Hm67FcZPzJpqMgxRVsXbDmJiVLGiRtZIqk,8805
         | 
| 79 79 | 
             
            geo_activity_playground/webui/summary/templates/summary/index.html.j2,sha256=rsII1eMY-xNugh8A9SecnEcDZqkEOWYIfiHAGroQYuM,4442
         | 
| 80 80 | 
             
            geo_activity_playground/webui/templates/home.html.j2,sha256=23MLQJ1k447NMLcgOGgTSNiPXFvdC2bQvACkDZbGo5k,2182
         | 
| 81 81 | 
             
            geo_activity_playground/webui/templates/page.html.j2,sha256=aeTYem0CpOOPvWa5KzVKH1BiPJlF0LHqChL1IhpAUO0,7292
         | 
| @@ -88,8 +88,8 @@ geo_activity_playground/webui/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeu | |
| 88 88 | 
             
            geo_activity_playground/webui/upload/blueprint.py,sha256=2l5q1LYtjgLF_3CAyPvCLx-wMebp14OJvgZBzGILdmQ,801
         | 
| 89 89 | 
             
            geo_activity_playground/webui/upload/controller.py,sha256=QrHfqRxroLuzBBNNSheUx-qJ9ww1sXT1oPdpS7Jx_ro,4092
         | 
| 90 90 | 
             
            geo_activity_playground/webui/upload/templates/upload/index.html.j2,sha256=hfXkEXaz_MkM46rU56423D6V6WtK-EAXPszSY-_-Tx8,1471
         | 
| 91 | 
            -
            geo_activity_playground-0.24. | 
| 92 | 
            -
            geo_activity_playground-0.24. | 
| 93 | 
            -
            geo_activity_playground-0.24. | 
| 94 | 
            -
            geo_activity_playground-0.24. | 
| 95 | 
            -
            geo_activity_playground-0.24. | 
| 91 | 
            +
            geo_activity_playground-0.24.2.dist-info/LICENSE,sha256=4RpAwKO8bPkfXH2lnpeUW0eLkNWglyG4lbrLDU_MOwY,1070
         | 
| 92 | 
            +
            geo_activity_playground-0.24.2.dist-info/METADATA,sha256=Rele9lf2wXKFJkEXlZYiRY8AMzjTwwN9RBvYY9ieAkc,1665
         | 
| 93 | 
            +
            geo_activity_playground-0.24.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
         | 
| 94 | 
            +
            geo_activity_playground-0.24.2.dist-info/entry_points.txt,sha256=pbNlLI6IIZIp7nPYCfAtiSiz2oxJSCl7DODD6SPkLKk,81
         | 
| 95 | 
            +
            geo_activity_playground-0.24.2.dist-info/RECORD,,
         | 
    
        {geo_activity_playground-0.24.1.dist-info → geo_activity_playground-0.24.2.dist-info}/LICENSE
    RENAMED
    
    | 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |