Example #1
0
def get_all_channel_db(db: Session):
    channels = db.query(channel.Channel).all()
    for c in channels:
        c.number_of_manager = crud_channel_manager.count_manager_of_channel(
            db=db, channel_id=c.id)
        c.number_of_shop = crud_shop.count_shop(db=db, channel_id=c.id)
    return channels
Example #2
0
def get_all_channel(db: Session, skip: int = 0, limit: int = 100):
    channels = db.query(channel.Channel).offset(skip).limit(limit).all()
    for c in channels:
        c.number_of_manager = crud_channel_manager.count_manager_of_channel(
            db=db, channel_id=c.id)
        c.number_of_shop = crud_shop.count_shop(db=db, channel_id=c.id)
    return channels
Example #3
0
def Count_shop_of_channel(
    channel_id:str,
    current_user= Security(deps.get_current_active_user,scopes=["read_channel"]),
    db: Session = Depends(deps.get_db)
):
    if crud_channel.get_channel(db=db,channel_id=channel_id) is None:
        raise UnicornException(
        messages="CHANNEL ID NOT FOUND",
        name=channel_id
        )
    return crud_shop.count_shop(db=db,channel_id=channel_id)
Example #4
0
def Count_shop_of_channel(channel_id: str,
                          token: Optional[str] = Header(None),
                          db: Session = Depends(deps.get_db)):
    try:
        check_sercurity_scopes(token=token,
                               scopes=settings.VIEW_CHANNEL_DETAIL_SCOPE)
    except (JWTError, ValidationError):
        raise HTTPException(
            status_code=status.HTTP_401_UNAUTHORIZED,
            detail="Unauthorized ",
            headers={"WWW-Authenticate": "Bearer"},
        )
    except (mysql.connector.Error):
        raise HTTPException(
            status_code=status.HTTP_502_BAD_GATEWAY,
            detail="My sql connection error ",
            headers={"WWW-Authenticate": "Bearer"},
        )
    return crud_shop.count_shop(db=db, channel_id=channel_id)
Example #5
0
def Count_shop_of_channel(channel_id: str,
                          current_user=Security(deps.get_current_active_user,
                                                scopes=["read_channel"]),
                          db: Session = Depends(deps.get_db)):
    return crud_shop.count_shop(db=db, channel_id=channel_id)