<commit_before>defimpl Canada.Can, for: CoursePlanner.User do
  alias CoursePlanner.{
    AttendanceController,
    OfferedCourseController,
    ScheduleController,
    Tasks.Task,
    User,
  }

  def can?(%User{role: "Coordinator"}, _action, _controller), do: true

  def can?(%User{role: "Teacher"}, _action, AttendanceController), do: true
  def can?(%User{role: "Teacher"}, action, OfferedCourseController)
    when action in [:index, :show, :edit, :update], do: true

  def can?(%User{role: "Student"}, action, AttendanceController)
    when action in [:show, :index], do: true
  def can?(%User{role: "Student"}, action, OfferedCourseController)
    when action in [:index, :show], do: true

  def can?(%User{role: "Volunteer", id: id}, :show, %Task{user_id: id}), do: true
  def can?(%User{role: "Volunteer"}, :index, Task), do: true
  def can?(%User{role: "Volunteer"}, :grab, %Task{}), do: true
  def can?(%User{role: "Volunteer"}, :show, %Task{user_id: nil}), do: true

  def can?(_user, _action, ScheduleController), do: true

  def can?(%User{id: id}, action, %User{id: id})
    when action in [:show, :edit, :update], do: true

  def can?(_user, _action, _controller), do: false
end
<commit_msg>Let actions in the same order<commit_after>defimpl Canada.Can, for: CoursePlanner.User do
  alias CoursePlanner.{
    AttendanceController,
    OfferedCourseController,
    ScheduleController,
    Tasks.Task,
    User,
  }

  def can?(%User{role: "Coordinator"}, _action, _controller), do: true

  def can?(%User{role: "Teacher"}, _action, AttendanceController), do: true
  def can?(%User{role: "Teacher"}, action, OfferedCourseController)
    when action in [:index, :show, :edit, :update], do: true

  def can?(%User{role: "Student"}, action, AttendanceController)
    when action in [:index, :show], do: true
  def can?(%User{role: "Student"}, action, OfferedCourseController)
    when action in [:index, :show], do: true

  def can?(%User{role: "Volunteer", id: id}, :show, %Task{user_id: id}), do: true
  def can?(%User{role: "Volunteer"}, :index, Task), do: true
  def can?(%User{role: "Volunteer"}, :grab, %Task{}), do: true
  def can?(%User{role: "Volunteer"}, :show, %Task{user_id: nil}), do: true

  def can?(_user, _action, ScheduleController), do: true

  def can?(%User{id: id}, action, %User{id: id})
    when action in [:show, :edit, :update], do: true

  def can?(_user, _action, _controller), do: false
end

{'fraction_non_alphanumeric': 0.16858552631578946, 'fraction_numerical': 0.0, 'mean_word_length': 5.022277227722772, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1059227', 'n_tokens_mistral': 842, 'n_tokens_neox': 827, 'n_words': 251}