improve achievement management and and views
This commit is contained in:
32
app/controllers/achievements_controller.rb
Normal file
32
app/controllers/achievements_controller.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AchievementsController < ProtectedController
|
||||
def index
|
||||
@wow_achievement_categories = WowAchievementCategory.base_categories.order(display_order: :asc)
|
||||
@wow_achievements = nil
|
||||
@wow_last_completed_achievements = CompletedWowAchievement.where(
|
||||
wow_character: current_user.wow_characters
|
||||
).includes(:wow_character, wow_achievement: :wow_achievement_criterium).order(completed_timestamp: :desc).first(5)
|
||||
@wow_achievement_category = nil
|
||||
end
|
||||
|
||||
def show
|
||||
@wow_achievement_category = WowAchievementCategory.find(params[:id])
|
||||
@wow_achievement_categories = @wow_achievement_category.child_categories.order(display_order: :asc)
|
||||
@wow_achievements = @wow_achievement_category.wow_achievements.includes(
|
||||
wow_achievement_criterium: :child_criteria
|
||||
).order(display_order: :asc)
|
||||
end
|
||||
end
|
||||
|
||||
# TODO
|
||||
# Find a way to get the last achievement accomplished that were not already achievement by another character
|
||||
# This will return all WowAchievement only completed by one character of the current user
|
||||
# achievements = WowAchievement.joins(:completed_wow_achievements).where('completed_wow_achievements.wow_character_id': current_user.wow_characters).group(:id).having("count(completed_wow_achievements.id) < 2")
|
||||
#
|
||||
# This will return all the CompletedWowAchievement of the previous list
|
||||
# completed_achievements = CompletedWowAchievement.where(wow_character: current_user.wow_characters, wow_achievement: achievements)
|
||||
#
|
||||
# The problem is that these completed_achivements all have a completed_timestamp at Thu, 01 Jan 1970 00:00:00.000000000 UTC +00:00
|
||||
#
|
||||
# It's probably required to use the WowAchievementCriterium to sort that
|
||||
Reference in New Issue
Block a user