| @@ -18,9 +18,10 @@ class Users::IsPinnedProjectsController < Users::BaseController | |||||
| private | private | ||||
| def is_pinned_project_ids | def is_pinned_project_ids | ||||
| if params[:is_pinned_project_ids].present? | if params[:is_pinned_project_ids].present? | ||||
| return params[:is_pinned_project_ids].select{|id| observed_user.full_member_projects.pluck(:id).include?(id.to_i) } | |||||
| return params[:is_pinned_project_ids].select{|id| observed_user.full_member_projects.visible.pluck(:id).include?(id.to_i) } | |||||
| end | end | ||||
| if params[:is_pinned_project_id].present? | if params[:is_pinned_project_id].present? | ||||
| return observed_user.is_pinned_project_ids unless observed_user.full_member_projects.visible.pluck(:id).include?(params[:is_pinned_project_id].to_i) | |||||
| return observed_user.is_pinned_project_ids.include?(params[:is_pinned_project_id].to_i) ? observed_user.is_pinned_project_ids : observed_user.is_pinned_project_ids.push(params[:is_pinned_project_id].to_i) | return observed_user.is_pinned_project_ids.include?(params[:is_pinned_project_id].to_i) ? observed_user.is_pinned_project_ids : observed_user.is_pinned_project_ids.push(params[:is_pinned_project_id].to_i) | ||||
| end | end | ||||
| end | end | ||||
| @@ -0,0 +1,11 @@ | |||||
| class Users::ProjectTrendsController < Users::BaseController | |||||
| def index | |||||
| if params[:date].present? | |||||
| @project_trends = observed_user.project_trends.where("DATE(created_at) = ?", params[:date]) | |||||
| else | |||||
| @project_trends = observed_user.project_trends | |||||
| end | |||||
| @project_trends = kaminari_paginate(@project_trends.includes(:trend, :project).order(created_at: :desc)) | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,2 @@ | |||||
| class Users::StatisticController < Users::BaseController | |||||
| end | |||||
| @@ -1,4 +1,7 @@ | |||||
| json.name issue.try(:subject) | json.name issue.try(:subject) | ||||
| json.issue_type issue.try(:issue_type) | |||||
| json.status_id issue.try(:status_id) | |||||
| json.priority_id issue.try(:priority_id) | |||||
| json.created_at format_time(issue.try(:created_on)) | json.created_at format_time(issue.try(:created_on)) | ||||
| json.updated_at format_time(issue.try(:updated_on)) | json.updated_at format_time(issue.try(:updated_on)) | ||||
| json.assign_user_name issue&.get_assign_user.try(:show_real_name) | json.assign_user_name issue&.get_assign_user.try(:show_real_name) | ||||
| @@ -0,0 +1,17 @@ | |||||
| json.id trend.id | |||||
| json.trend_type trend.trend_type | |||||
| json.action_type l("trend.#{trend.action_type}") + l("trend.#{trend.trend_type}") | |||||
| json.trend_id trend.trend_id | |||||
| json.user_name trend.user.try(:show_real_name) | |||||
| json.user_login trend.user.login | |||||
| json.user_avatar url_to_avatar(trend.user) | |||||
| json.action_time time_from_now(trend.created_at) | |||||
| if trend.trend_type == "Issue" | |||||
| json.partial! "issues/simple_issue_item", locals: {issue: trend.trend} | |||||
| elsif trend.trend_type == "VersionRelease" | |||||
| json.partial! "version_releases/simple_version_release", locals: {version: trend.trend} | |||||
| else | |||||
| json.name trend.trend.title | |||||
| json.created_at format_time(trend.trend.created_at) | |||||
| end | |||||
| @@ -9,25 +9,9 @@ json.limit @limit | |||||
| json.project_trends_size @project_trends_size | json.project_trends_size @project_trends_size | ||||
| json.project_trends do | json.project_trends do | ||||
| json.array! @project_trends.to_a.each do |trend| | json.array! @project_trends.to_a.each do |trend| | ||||
| json.id trend.id | |||||
| json.trend_type trend.trend_type | |||||
| json.action_type l("trend.#{trend.action_type}") + l("trend.#{trend.trend_type}") | |||||
| json.trend_id trend.trend_id | |||||
| json.user_name trend.user.try(:show_real_name) | |||||
| json.user_login trend.user.login | |||||
| json.user_avatar url_to_avatar(trend.user) | |||||
| if trend.trend_type == "Issue" | |||||
| json.partial! "issues/simple_issue_item", locals: {issue: trend.trend} | |||||
| elsif trend.trend_type == "VersionRelease" | |||||
| json.partial! "version_releases/simple_version_release", locals: {version: trend.trend} | |||||
| else | |||||
| json.name trend.trend.title | |||||
| json.created_at format_time(trend.trend.created_at) | |||||
| end | |||||
| #后续需要天际pullrequest 和 版本的内容 | #后续需要天际pullrequest 和 版本的内容 | ||||
| json.partial! "detail", trend: trend | |||||
| end | end | ||||
| end | end | ||||
| @@ -0,0 +1,4 @@ | |||||
| json.total_count @project_trends.total_count | |||||
| json.project_trends @project_trends.each do |trend| | |||||
| json.partial! "project_trends/detail", trend: trend | |||||
| end | |||||
| @@ -271,6 +271,7 @@ Rails.application.routes.draw do | |||||
| post :pin | post :pin | ||||
| end | end | ||||
| end | end | ||||
| resources :project_trends, only: [:index] | |||||
| resources :organizations, only: [:index] | resources :organizations, only: [:index] | ||||
| # resources :projects, only: [:index] | # resources :projects, only: [:index] | ||||
| # resources :subjects, only: [:index] | # resources :subjects, only: [:index] | ||||