本文整理汇总了Python中vilya.models.ticket.Ticket.get_count_by_proj_id方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.get_count_by_proj_id方法的具体用法?Python Ticket.get_count_by_proj_id怎么用?Python Ticket.get_count_by_proj_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vilya.models.ticket.Ticket
的用法示例。
在下文中一共展示了Ticket.get_count_by_proj_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import get_count_by_proj_id [as 别名]
def search(self, request):
key_word = request.get_form_var('q')
if not key_word:
return self._index(request)
status = request.get_form_var('status')
user = request.user
page = request.get_form_var('page', 1)
project = self.project
tickets = []
ticket_len = Ticket.get_count_by_proj_id(project.id)
search_result = PullRequestSearch.search_a_phrase(
key_word, project.id, size=ticket_len)
if search_result and not search_result.get('error'):
ticket_ids = [id for id, in SearchEngine.decode(
search_result, ['ticket_id'])]
tickets = Ticket.gets_by_projectid_and_ticketnumbers(
project.id, ticket_ids)
if status == "closed":
tickets = [t for t in tickets if t.closed]
else:
tickets = [t for t in tickets if not t.closed]
ticket_total_len = len(tickets)
limit = TICKETS_COUNT_PER_PAGE
start = TICKETS_COUNT_PER_PAGE * (int(page) - 1)
tickets = tickets[start:start + limit]
n_pages = (ticket_total_len - 1) / TICKETS_COUNT_PER_PAGE + 1
if status == "closed":
is_closed_tab = True
else:
is_closed_tab = False
open_tab_link = self.open_tab_link
close_tab_link = self.close_tab_link
return st('/pull/pulls.html', **locals())
示例2: add_pull
# 需要导入模块: from vilya.models.ticket import Ticket [as 别名]
# 或者: from vilya.models.ticket.Ticket import get_count_by_proj_id [as 别名]
def add_pull(ticket, pullreq, user):
from dispatches import dispatch
from vilya.libs.text import get_mentions_from_text
from vilya.libs.signals import pullrequest_signal
from vilya.models.user import get_author_by_email
from vilya.models.user import User
from vilya.models.trello.core import process_trello_notify
reporter = user.username
commits = pullreq.commits
# TODO: refactory is! auto number how to?
shas = [p.sha for p in commits]
ticket_len = Ticket.get_count_by_proj_id(ticket.project_id)
if ticket_len == 0:
# 检查是否创建过新PR,若未创建过则以旧PR号为基准累加
max_ticket_id = PullRequest.get_max_ticket_id(ticket.project_id)
if max_ticket_id >= 0:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author,
max_ticket_id + 1)
else:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author)
else:
ticket = Ticket.add(ticket.project_id,
ticket.title,
ticket.description,
ticket.author)
pullreq = pullreq.insert(ticket.ticket_number)
if shas:
ticket.add_commits(','.join(shas), reporter)
noti_receivers = [committer.name
for committer in CodeDoubanProject.get_committers_by_project(pullreq.to_proj.id)] # noqa
noti_receivers = noti_receivers + [pullreq.to_proj.owner.name]
get_commit_author = lambda u: get_author_by_email(u.email.encode('utf-8'))
commit_authors = {get_commit_author(c.author) for c in commits}
commit_authors = {a for a in commit_authors if a}
noti_receivers.extend(commit_authors)
# diffs, author_by_file, authors = pullreq.get_diffs(with_blame=True)
# FIXME: diffs没用到?
# diffs = pullreq.get_diffs()
# blame代码变更的原作者, 也加到at users
at_users = get_mentions_from_text(ticket.description)
# at_users.extend(authors)
at_users.append(pullreq.to_proj.owner_id)
at_users = set(at_users)
# FIXME: invited_users is used on page /hub/my_pull_requests/
invited_users = [User(u).add_invited_pull_request(ticket.id)
for u in at_users]
ProjectOwnLRUCounter(user.username).use(pullreq.to_proj.id)
ProjectWatchLRUCounter(user.username).use(pullreq.to_proj.id)
# TODO: 重构Feed之后取消这个信号的发送
pullrequest_signal.send(user.username,
extra_receivers=noti_receivers,
pullreq=pullreq,
comment=ticket.description,
ticket_id=ticket.ticket_id,
ticket=ticket,
status="unmerge",
new_version=True)
dispatch('pullreq',
data=dict(sender=user.username,
content=ticket.description,
ticket=ticket,
status='unmerge',
new_version=True,
extra_receivers=noti_receivers))
dispatch('pr_actions',
data=dict(type='pr_opened',
hooks=pullreq.to_proj.hooks,
author=user,
title=ticket.title,
body=ticket.description,
ticket=ticket,
pullreq=pullreq))
# FIXME: move to dispatch
process_trello_notify(user, ticket)
return pullreq