~homeworkprod/byceps

f1e69db7b7cb5b3dbc4cb67a02916bd086a1a90a — Jochen Kupperschmidt 1 year, 5 months ago af57247
Remove news item counts from admin brands index
M byceps/blueprints/admin/brand/templates/admin/brand/index.html => byceps/blueprints/admin/brand/templates/admin/brand/index.html +0 -2
@@ 21,7 21,6 @@
        <th>Name<br>ID</th>
        <th class="centered">Partys</th>
        <th class="centered">Organisatoren</th>
        <th class="centered">Newsposts</th>
      </tr>
    </thead>
    <tbody>


@@ 33,7 32,6 @@
        </td>
        <td class="centered bignumber">{{ party_count_by_brand_id[brand.id] }}</td>
        <td class="centered bignumber">{{ orga_count_by_brand_id[brand.id] }}</td>
        <td class="centered bignumber">{{ news_item_count_by_brand_id[brand.id] }}</td>
      </tr>
      {%- endfor %}
    </tbody>

M byceps/blueprints/admin/brand/views.py => byceps/blueprints/admin/brand/views.py +0 -4
@@ 12,7 12,6 @@ from ....services.brand import (
    service as brand_service,
    settings_service as brand_settings_service,
)
from ....services.news import service as news_service
from ....services.orga import service as orga_service
from ....services.party import service as party_service
from ....util.framework.blueprint import create_blueprint


@@ 44,13 43,10 @@ def index():

    orga_count_by_brand_id = orga_service.get_person_count_by_brand_id()

    news_item_count_by_brand_id = news_service.get_item_count_by_brand_id()

    return {
        'brands': brands,
        'party_count_by_brand_id': party_count_by_brand_id,
        'orga_count_by_brand_id': orga_count_by_brand_id,
        'news_item_count_by_brand_id': news_item_count_by_brand_id,
    }



M byceps/services/news/service.py => byceps/services/news/service.py +0 -17
@@ 13,8 13,6 @@ from ...database import db, paginate, Pagination, Query
from ...events.news import NewsItemPublished
from ...typing import BrandID, UserID

from ..brand.models.brand import Brand as DbBrand

from .channel_service import _db_entity_to_channel
from .models.channel import Channel as DbChannel
from .models.item import (


@@ 234,21 232,6 @@ def count_items_for_brand(brand_id: BrandID) -> int:
        .count()


def get_item_count_by_brand_id() -> Dict[BrandID, int]:
    """Return news item count (including 0) per brand, indexed by brand ID."""
    brand_ids_and_item_counts = db.session \
        .query(
            DbBrand.id,
            db.func.count(DbItem.id)
        ) \
        .outerjoin(DbChannel, DbChannel.brand_id == DbBrand.id) \
        .outerjoin(DbItem) \
        .group_by(DbBrand.id) \
        .all()

    return dict(brand_ids_and_item_counts)


def get_item_count_by_channel_id() -> Dict[ChannelID, int]:
    """Return news item count (including 0) per channel, indexed by
    channel ID.