Skip to content

Commit 52c88d0

Browse files
committed
un-nest flair_id
Signed-off-by: Steven Hoffman <fustrate@me.com>
1 parent 4264bab commit 52c88d0

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/baseballbot/posts/game_thread.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ def post_postgame!
128128
Baseballbot::Posts::Postgame.new(@row, subreddit:).create!
129129
end
130130

131-
def game_thread_flair(type) = subreddit.options.dig('game_threads', 'flair_id', type)
131+
def game_thread_flair(type)
132+
subreddit.options.dig('game_threads', "flair_id.#{type}") || subreddit.options.dig('game_threads', 'flair_id')
133+
end
132134

133135
def post_template(type) = Templates::GameThread.new(subreddit:, game_pk:, post_id: @post_id, type:, title:)
134136

lib/baseballbot/posts/postgame.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ def post_process
3434
end
3535

3636
def flair_id
37-
flair = @subreddit.options.dig('postgame', 'flair_id')
38-
39-
return unless flair
37+
if template.won? && @subreddit.options.dig('postgame', 'flair_id.won')
38+
return @subreddit.options.dig('postgame', 'flair_id.won')
39+
end
4040

41-
return flair['won'] if flair['won'] && template.won?
42-
return flair['lost'] if flair['lost'] && template.lost?
41+
if template.lost? && @subreddit.options.dig('postgame', 'flair_id.lost')
42+
return @subreddit.options.dig('postgame', 'flair_id.lost')
43+
end
4344

44-
flair['default']
45+
@subreddit.options.dig('postgame', 'flair_id')
4546
end
4647

4748
def post_sticky_comment = post_comment(text: subreddit.options.dig('postgame', 'sticky_comment'))

0 commit comments

Comments
 (0)