Skip to content

Commit a1517d3

Browse files
committed
chore: normalize line endings in serializer files
- Fix line endings in OrganizationSerializer - Fix line endings in UserSerializer - Ensure consistent formatting across serializers - No functional changes
1 parent b667e57 commit a1517d3

2 files changed

Lines changed: 99 additions & 99 deletions

File tree

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
class OrganizationSerializer
2-
include Blueprinter::Base
3-
4-
identifier :id
5-
6-
fields :name, :slug, :region, :tier, :subscription_plan, :subscription_status,
7-
:logo_url, :settings, :created_at, :updated_at
8-
9-
field :region_display do |org|
10-
region_names = {
11-
'BR' => 'Brazil',
12-
'NA' => 'North America',
13-
'EUW' => 'Europe West',
14-
'EUNE' => 'Europe Nordic & East',
15-
'KR' => 'Korea',
16-
'LAN' => 'Latin America North',
17-
'LAS' => 'Latin America South',
18-
'OCE' => 'Oceania',
19-
'RU' => 'Russia',
20-
'TR' => 'Turkey',
21-
'JP' => 'Japan'
22-
}
23-
24-
region_names[org.region] || org.region
25-
end
26-
27-
field :tier_display do |org|
28-
return 'Not set' if org.tier.blank?
29-
30-
org.tier.humanize
31-
end
32-
33-
field :subscription_display do |org|
34-
return 'Free' if org.subscription_plan.blank?
35-
36-
plan = org.subscription_plan.humanize
37-
status = org.subscription_status&.humanize || 'Active'
38-
39-
"#{plan} (#{status})"
40-
end
41-
42-
field :statistics do |org|
43-
{
44-
total_players: org.players.count,
45-
active_players: org.players.active.count,
46-
total_matches: org.matches.count,
47-
recent_matches: org.matches.recent(30).count,
48-
total_users: org.users.count
49-
}
50-
end
1+
class OrganizationSerializer
2+
include Blueprinter::Base
3+
4+
identifier :id
5+
6+
fields :name, :slug, :region, :tier, :subscription_plan, :subscription_status,
7+
:logo_url, :settings, :created_at, :updated_at
8+
9+
field :region_display do |org|
10+
region_names = {
11+
'BR' => 'Brazil',
12+
'NA' => 'North America',
13+
'EUW' => 'Europe West',
14+
'EUNE' => 'Europe Nordic & East',
15+
'KR' => 'Korea',
16+
'LAN' => 'Latin America North',
17+
'LAS' => 'Latin America South',
18+
'OCE' => 'Oceania',
19+
'RU' => 'Russia',
20+
'TR' => 'Turkey',
21+
'JP' => 'Japan'
22+
}
23+
24+
region_names[org.region] || org.region
25+
end
26+
27+
field :tier_display do |org|
28+
return 'Not set' if org.tier.blank?
29+
30+
org.tier.humanize
31+
end
32+
33+
field :subscription_display do |org|
34+
return 'Free' if org.subscription_plan.blank?
35+
36+
plan = org.subscription_plan.humanize
37+
status = org.subscription_status&.humanize || 'Active'
38+
39+
"#{plan} (#{status})"
40+
end
41+
42+
field :statistics do |org|
43+
{
44+
total_players: org.players.count,
45+
active_players: org.players.active.count,
46+
total_matches: org.matches.count,
47+
recent_matches: org.matches.recent(30).count,
48+
total_users: org.users.count
49+
}
50+
end
5151
end

app/serializers/user_serializer.rb

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
class UserSerializer
2-
include Blueprinter::Base
3-
4-
identifier :id
5-
6-
fields :email, :full_name, :role, :avatar_url, :timezone, :language,
7-
:notifications_enabled, :notification_preferences, :last_login_at,
8-
:created_at, :updated_at
9-
10-
field :role_display do |user|
11-
user.full_role_name
12-
end
13-
14-
field :permissions do |user|
15-
{
16-
can_manage_users: user.can_manage_users?,
17-
can_manage_players: user.can_manage_players?,
18-
can_view_analytics: user.can_view_analytics?,
19-
is_admin_or_owner: user.admin_or_owner?
20-
}
21-
end
22-
23-
field :last_login_display do |user|
24-
if user.last_login_at
25-
time_ago_in_words(user.last_login_at)
26-
else
27-
'Never'
28-
end
29-
end
30-
31-
private
32-
33-
def self.time_ago_in_words(time)
34-
return 'Never' if time.nil?
35-
36-
diff = Time.current - time
37-
case diff
38-
when 0...60
39-
"#{diff.to_i} seconds ago"
40-
when 60...3600
41-
"#{(diff / 60).to_i} minutes ago"
42-
when 3600...86400
43-
"#{(diff / 3600).to_i} hours ago"
44-
when 86400...2592000
45-
"#{(diff / 86400).to_i} days ago"
46-
else
47-
time.strftime('%B %d, %Y')
48-
end
49-
end
1+
class UserSerializer
2+
include Blueprinter::Base
3+
4+
identifier :id
5+
6+
fields :email, :full_name, :role, :avatar_url, :timezone, :language,
7+
:notifications_enabled, :notification_preferences, :last_login_at,
8+
:created_at, :updated_at
9+
10+
field :role_display do |user|
11+
user.full_role_name
12+
end
13+
14+
field :permissions do |user|
15+
{
16+
can_manage_users: user.can_manage_users?,
17+
can_manage_players: user.can_manage_players?,
18+
can_view_analytics: user.can_view_analytics?,
19+
is_admin_or_owner: user.admin_or_owner?
20+
}
21+
end
22+
23+
field :last_login_display do |user|
24+
if user.last_login_at
25+
time_ago_in_words(user.last_login_at)
26+
else
27+
'Never'
28+
end
29+
end
30+
31+
private
32+
33+
def self.time_ago_in_words(time)
34+
return 'Never' if time.nil?
35+
36+
diff = Time.current - time
37+
case diff
38+
when 0...60
39+
"#{diff.to_i} seconds ago"
40+
when 60...3600
41+
"#{(diff / 60).to_i} minutes ago"
42+
when 3600...86400
43+
"#{(diff / 3600).to_i} hours ago"
44+
when 86400...2592000
45+
"#{(diff / 86400).to_i} days ago"
46+
else
47+
time.strftime('%B %d, %Y')
48+
end
49+
end
5050
end

0 commit comments

Comments
 (0)