Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.7.0 #93

Merged
merged 2 commits into from
Jun 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# suikoden-election-2021-database
幻水総選挙2021 データベース

- 幻水総選挙 2021 データベース

# コマンド集

## データベースに格納してあるユーザーの公開状態を全チェックし、データの更新する

```bash
$ $(which bundle) exec rails runner "TwitterRestApi::CheckProtectedUsers.new.update_all_user_is_protected_statuses"
```

## データベースに格納してあるツイートの公開状態を全チェックし、データの更新する

```
$(which bundle) exec rails runner "TwitterRestApi::CheckPublicTweets.new.update_all_tweet_is_public_statuses"
```

## 特定の「ハッシュタグ」のツイートを、特定の「スプレッドシート」の「シート」に書き込む(全上書き)

- `#execute` の引数の意味は次の通り
- 第二引数はツイートの絞り込み条件を与える
- 第三引数はログに追加するハッシュを与える
- 第四引数(キーワード引数)は `all_overwrite: true` でシートの全上書きをする
- 指定しない場合には追記になるが、追記の場合はツイートやユーザーの公開状態が更新されない

```bash
$ $(which bundle) exec rails runner "GoogleSheetApi::WriteToResponseApiSheetByHashtag.new(spreadsheet_id: 'スプレッドシートのID', sheet_name: 'シート名').execute('対象のハッシュタグ(# は不要)', { remove_rt: true, not_by_gensosenkyo: true, end_at: Time.zone.parse('2021-06-11 01:00:00') }, {}, all_overwrite: true);"
```
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def target_tweets(hashtag, options={})
tweeted_at: beginning_at..end_at
)
active_record_relation = active_record_relation.not_retweet if options[:remove_rt] == true
active_record_relation = active_record_relation.not_by_gensosenkyo if options[:not_by_gensosenkyo] == true
active_record_relation = active_record_relation.not_by_gensosenkyo_families if options[:not_by_gensosenkyo_families] == true

if end_search_tweet_id_number.present?
active_record_relation = active_record_relation.where(
Expand Down
20 changes: 18 additions & 2 deletions app/models/tweet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,30 @@ def self.filter_by_tweeted_at(from, to)
where(tweeted_at: from..to)
end

def self.not_by_gensosenkyo
def self.not_by_gensosenkyo_families
# gensosenkyo: 1471724029,
# sub_gensosenkyo: 1388758231825018881

target_user_ids = [
User.find_by(id_number: 1471724029)&.id,
User.find_by(id_number: 1388758231825018881)&.id,
].compact!
].compact

where.not(user_id: target_user_ids)
end

def self.not_by_gensosenkyo_main
target_user_ids = [
User.find_by(id_number: 1471724029)&.id,
].compact

where.not(user_id: target_user_ids)
end

def self.not_by_gensosenkyo_sub
target_user_ids = [
User.find_by(id_number: 1388758231825018881)&.id,
].compact

where.not(user_id: target_user_ids)
end
Expand Down