TIL

# 211209 TIL ([Ruby, slim] 함수 매개변수 사용하여 쿼리하기)

장기현장실습

PLSnote 이슈

#2678 노트작성 버튼이 나타나는 곳을  확대하고자 합니다 이슈 진행중 

  • 맵/전략/세부전략 에서  노트 작성시 나올 프로젝트 리스트 코드 리팩토링 
    • 원래 이슈맵일때와 아닐 때의 함수를 따로 정의했었는데 이걸 하나로 합쳤다.
      # project.rb
      
      def self.has_project_of_detailed_strategy(detailed_strategy)
        if detailed_strategy.map.issue_map?
          where(id: detailed_strategy.issues.where(status: :open_issue).pluck(:project_id))
        else
          where(id: detailed_strategy.plans.where(status: :open_plan).pluck(:project_id))
        end
      end

  • 맵/본부/팀 에서  노트 작성시 나올 프로젝트 리스트 코드 리팩토링 
    • 이슈맵일  나오게 작성했던 코드가 잘못된 쿼리를 하고 있었다. issue_team_order 테이블의 order 컬럼에서 가장  값인 row. 그 row의 이슈를 현재 맡고 있는 팀은 order 컬럼이 가장  값이라고 쿼리했는데 그게 아니였다. Order 컬럼의 값은 이슈  경로를 지정할  생기는 거고, 이슈를 현재 어떤 팀이 하고 있는지는 issue 테이블의 issue_team_order_id  보고  id가 일치하는 row의 team_id를 보면된다. 이 쿼리를 이미 해둔 함수?가 있었다.. team.rb에 project_has_planable이라는 함수이다. 
      • 여기서 한가지 빠진 점은 확인전 계획 또는 이슈가 있는 프로젝트 리스트만 가져와야하는 것이었다. 그래서 open_status라는 매개변수를 주고 없을 때는 nil을 넣어주어 기존 코드에 영향이 가지 않도록 했다.
        # team.rb
        
        #- 맵 내에 팀이 일정을 가지고 있는 프로젝트
        def project_has_planable(open_status = nil) 
          if head_quarter.map.issue_map? 
            issue_team_orders = IssueTeamOrder.where(team_id: self).distinct 
            head_quarter.map.projects.joins(:issues).where(issues: {issue_team_order: issue_team_orders, status: open_status}).distinct 
          else 
            head_quarter.map.projects.joins(:plans).where(plans: {team_id: self, status: open_status}).distinct 
          end 
        end
        // activities/_form.html.slim
        
        .form-group
          = f.label :project, t('project')
          - if @map.issue_map?
            - if @team.present?
              = f.collection_select :project_id, @team.project_has_planable(:open_issue).proper_order, :id, :name, {selected: @planable&.id}, {class: 'form-control', data: {action: 'change->activity#selectTeam'}, "select-team-url": select_team_map_activities_path(@map)}
            - elsif @detailed_strategy.present?
              = f.collection_select :project_id, @detailed_strategy.projects.has_project_of_detailed_strategy(@detailed_strategy).proper_order.distinct, :id, :name, {selected: @planable&.id}, {class: 'form-control', data: {action: 'change->activity#selectTeam'}, "select-team-url": select_team_map_activities_path(@map)}
          - else
            - if @team.present?
              = f.collection_select :project_id, @team.project_has_planable(:open_plan).proper_order, :id, :name, {selected: @planable&.id}, {class: 'form-control', data: {action: 'change->activity#selectTeam'}, "select-team-url": select_team_map_activities_path(@map)}
            - elsif @detailed_strategy.present?
              = f.collection_select :project_id, @detailed_strategy.projects.has_project_of_detailed_strategy(@detailed_strategy).proper_order.distinct, :id, :name, {selected: @planable&.id}, {class: 'form-control', data: {action: 'change->activity#selectTeam'}, "select-team-url": select_team_map_activities_path(@map)}

 

 

SNU 성문분석 이슈

#50 N:N 분석(시각화) 기능 추가 이슈 진행중 

  • N:N 분석에 유사도 결과, (x,y) 그래프 컴포넌트 추가 
    • 유사도 결과 컴포넌트 생성 (SmilarManyVoicesTable.tsx) 
      • 현재는 UI만 나타나게 해둔 상태이고 1:N 분석의 유사도 TOP5 컴포넌트를 가져와 수정해서 result를 OneToManyResult를 사용하고 있다. 이제 이걸 ManyToManyResult로 바꾸고 useMemo (테이블에 들어갈 결과 값들) 안의 내용을 수정해야한다.
    • (x,y) 그래프 컴포넌트 생성 (ManyToManyAnalysisGraph.tsx) 
      • 컴포넌트 안의 그래프는 1:1 분석의 우도 그래프이고, (x,y) 점을 찍는 그래프로 바꿔야하는 상태이다.