-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from true-runes/development
v3.3.0
- Loading branch information
Showing
21 changed files
with
838 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
class CountingBonusVote < ApplicationRecord | ||
include CountingTools | ||
|
||
belongs_to :tweet, optional: true | ||
belongs_to :direct_message, optional: true | ||
belongs_to :user # 鍵でも User のレコードは取得できるので optional 指定は不要 | ||
|
||
scope :invisible, -> { where(is_invisible: true) } | ||
scope :out_of_counting, -> { where(is_out_of_counting: true) } | ||
scope :valid_records, -> { where(is_out_of_counting: false).where(is_invisible: false) } | ||
scope :by_tweet, -> { where(vote_method: :by_tweet) } | ||
scope :by_dm, -> { where(vote_method: :by_direct_message) } | ||
|
||
enum vote_method: { by_tweet: 0, by_direct_message: 1, by_others: 99 }, _prefix: true | ||
enum bonus_category: { | ||
op_cl_illustrations: 0, | ||
short_stories: 1, | ||
result_illustrations: 2, | ||
fav_quotes: 3, | ||
sosenkyo_campaigns: 4 | ||
}, _prefix: true | ||
|
||
def theme_on_short_story | ||
# TODO: contents に「お題」が含まれている場合は、そのお題を返す | ||
end | ||
|
||
def self.all_fav_quote_character_names_including_duplicated | ||
chara_columns = %i[chara_01 chara_02 chara_03 chara_04 chara_05 chara_06 chara_07 chara_08 chara_09 chara_10] | ||
character_names = [] | ||
|
||
chara_columns.each do |column| | ||
character_names += CountingBonusVote.valid_records.where(bonus_category: :fav_quotes).pluck(column) | ||
end | ||
|
||
character_names.compact.reject(&:empty?).sort | ||
end | ||
|
||
def self.fav_quote_character_name_to_number_of_votes | ||
all_fav_quote_character_names_including_duplicated.tally.sort_by { |_, v| v }.reverse.to_h | ||
end | ||
|
||
def self.fav_quote_ranking_style | ||
Presenter::Counting.key_to_rank_number_by_sosenkyo_style(fav_quote_character_name_to_number_of_votes) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
class OnRawSheetResultIllustrationTotalling < ApplicationRecord | ||
# on_raw_sheet_result_illustration_totalling | ||
def convert_name_to_gensosenkyo_style(name) | ||
{ | ||
"ほげ" => "ほげげげ" | ||
}[name] || name | ||
end | ||
end | ||
|
||
# irb(main):003:0> x = { a: 1, b: 2, c: 3 } | ||
# irb(main):004:0> y = { a: 4, c: 5, d: 10 } | ||
# irb(main):007:0> x.merge(y) { |_, oldval, newval| oldval + newval } | ||
# => {:a=>5, :b=>2, :c=>8, :d=>10} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.