Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review/interview show #80

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Добавлена возможность просмотреть добавленные интервью компании (врем…
…енный вид)
Simon committed Jul 29, 2020
commit 02047871d2fe2f6a61af15b18652f75b554b49ef
1 change: 0 additions & 1 deletion apps/web/controllers/companies/show.rb
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ class Show

def call(params)
result = operation.call(id: params[:id])

case result
when Success
@company = result.value!
12 changes: 6 additions & 6 deletions apps/web/controllers/interviews/index.rb
Original file line number Diff line number Diff line change
@@ -10,15 +10,15 @@ class Index
interview_operation: 'interviews.operations.list'
]

expose :company, :interviews
expose :interviews, :company

def call(params)
result = operation.call(id: params[:id])

case result
result = interview_operation.call(company_id: params[:company_id].to_i)
company_result = operation.call(id: params[:company_id].to_i)
case result && company_result
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так нельзя делать, этот код всегда будет company_result пропускать

по идее, ты можешь переписать это вот так:

case company_result
when Success
  @company = company_result.value!
  @interviews = result.value_or([])
when Failure
  redirect_to routes.companies_path
end

when Success
@company = result.value!
@reviews = interview_operation.call(company_id: @company.id).value_or([])
@interviews = result.value_or([])
@company = company_result.value!
when Failure
redirect_to routes.companies_path
end
2 changes: 2 additions & 0 deletions apps/web/templates/interviews/index.html.slim
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
.col
h1
= link_to 'Компании', routes.companies_path
| > #{link_to company.name, routes.company_path(company.id)}
| > Список отзывов

.row.mt-3.mb-3
.col
4 changes: 3 additions & 1 deletion lib/interviews/operations/list.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@ class List < ::Libs::Operation
include Import[interview_repo: 'repositories.interview',]

def call(company_id:)
Success(interview_repo.all_for_companies(company_id))
Success(
interview_repo.all_for_companies(company_id)
)
end
end
end