def statistics_team_jobs(body): if "team_id" not in body: return team = Team.select().where(Team.id == body["team_id"]).first() if not team: return qs = (Job.team == team) qs_count = (qs & (Job.status << ["normal", "private", "close"])) qs_open = (qs & (Job.status == "normal")) jobs_count = Job.select().where(qs_count).count() jobs_open = Job.select().where(qs_open).count() ts = TeamStatistics().select().where(TeamStatistics.team == team).first() if not ts: ts = TeamStatistics() ts.user = team.user ts.team = team ts.jobs = 0 ts.open_jobs = 0 ts.jobs = jobs_count ts.open_jobs = jobs_open ts.save() return
def job_view(body): if "uuid" not in body or "user_id" not in body: return job = Job.select().where(Job.job_uuid==body["uuid"]).first() if not job or job.user_id != body["user_id"]: return job.last_view_time = utils.now() job.save() qs = Proposal.update(is_view=True).where(Proposal.job==job) qs.execute() return