Показать страницуИстория страницыСсылки сюдаCopy this pageExport to MarkdownODT преобразованиеНаверх Вы загрузили старую версию документа! Сохранив её, вы создадите новую текущую версию с этим содержимым. Медиафайлы{{tag>languages python book pip python-setuptools easy_install}} ====== Python - Документация ====== ===== Логика ===== <code python> (VotingAchievement.uuid == nomination_id) if nomination_id else True ~ VotingAchievement.uuid </code> ===== Alchemy ===== <code python> nominations = await self._session.execute( select(VotingAchievement).where( ~VotingAchievement.is_deleted, VotingAchievement.is_published, (VotingAchievement.uuid == nomination_id) if nomination_id else True, ).order_by(VotingAchievement.position).options( selectinload(VotingAchievement.icon), selectinload(VotingAchievement.preview) ) ) for nomination in nominations.scalars().all(): ... </code> <code python> result = [] for nomination in nominations.scalars().all(): query = select( ExponentVotesAggregation.uuid, ExponentVotesAggregation.title_ru, ExponentVotesAggregation.title_en, func.sum(ExponentVotesAggregation.count).label("count") ).where( ExponentVotesAggregation.created_at >= since, ExponentVotesAggregation.created_at <= till, ExponentVotesAggregation.nomination_id == nomination.uuid, ).group_by( ExponentVotesAggregation.uuid, ExponentVotesAggregation.title_ru, ExponentVotesAggregation.title_en, ).order_by(desc(text("count"))) exponents = await self._session.execute( query ) result.append((nomination, exponents.all(),)) </code> ===== Ссылки ===== {{topic>[python]}}СохранитьПросмотрРазличияОтменить Сводка изменений Примечание: редактируя эту страницу, вы соглашаетесь на использование своего вклада на условиях следующей лицензии: CC0 1.0 Universal