Comments (1)
現在実装されている1日分のページも含め、「前」や「次」が存在することがどういうことか決めておく必要がある。また、隣がメッセージの存在しない年・月・日だったときにそれを表示するかしないかの2つの方法が考えられる。
MessageDateモデル
ある日のログが存在するかは、現在の実装ではMessageDateのレコードが存在するかと等しい。MessageDateの1件分の内容はチャンネルと日付の組合せで、例えば「チャンネル #cre の2017-04-18のログが存在する」ことを表す。
Lines 68 to 73 in 1a75c03
MessageDateの例
id | channel_id | date |
---|---|---|
1 | 13 | 2017-04-18 |
2 | 1 | 2017-04-18 |
3 | 13 | 2017-04-19 |
... | ... | ... |
(この例では channel_id == 1
→ #cre、channel_id == 13
→ #もの書き)
MessageDateのレコードの追加
MessageDateは、IRCボットを使ったメッセージの記録の際に、MessageDate.find_or_create_by!
によって1日に1回だけ追加される。
log-archiver/lib/ircs/plugins/base.rb
Line 46 in b37f43c
log-archiver/lib/ircs/plugins/base.rb
Line 73 in b37f43c
log-archiver/lib/ircs/plugins/base.rb
Line 100 in b37f43c
前後の年が存在するか
年月(yyyy-mm)の選択画面。Channels::MonthsController#index
が担当する。
log-archiver/app/controllers/channels/months_controller.rb
Lines 2 to 14 in 1912727
チャンネルcにy年の前の年が存在するとは、チャンネルcかつy年1月1日より前のMessageDateが存在すること。調べるには以下のようにする。
MessageDate.
where(channel: c).
where('date < ?', Time.zone.local(y, 1, 1)).
exists?
同様に、チャンネルcにy年の後の年が存在するとは、チャンネルcかつyの翌年1月1日以降のMessageDateが存在すること。調べるには以下のようにする。
MessageDate.
where(channel: c).
where('date >= ?', Time.zone.local(y, 1, 1).next_year).
exists?
前後の月が存在するか
年月日(yyyy-mm-dd)の選択画面。Channels::DaysController#index
が担当する。
log-archiver/app/controllers/channels/days_controller.rb
Lines 2 to 16 in 1912727
チャンネルcにy年m月の前の月が存在するとは、チャンネルcかつy年m月1日より前のMessageDateが存在すること。調べるには以下のようにする。
MessageDate.
where(channel: c).
where('date < ?', Time.zone.local(y, m, 1)).
exists?
同様に、チャンネルcにy年m月の後の月が存在するとは、チャンネルcかつy年m月1日の翌月以降のMessageDateが存在すること。調べるには以下のようにする。
MessageDate.
where(channel: c).
where('date >= ?', Time.zone.local(y, m, 1).next_month).
exists?
前後の日が存在するか
1日分のログの画面。Channels#DaysController#show
が担当する。
log-archiver/app/controllers/channels/days_controller.rb
Lines 18 to 29 in 1912727
チャンネルcに日付dateの前の日が存在するとは、チャンネルcかつ日付dateより前のMessageDateが存在すること。調べるには以下のようにする。
MessageDate.
where(channel: c).
where('date < ?', date).
exists?
同様に、チャンネルcに日付dateの後の日が存在するとは、チャンネルcかつ日付dateより後のMessageDateが存在すること。調べるには以下のようにする。
MessageDate.
where(channel: c).
where('date > ?', date.
exists?
from log-archiver.
Related Issues (20)
- インストールドキュメントの整備
- Ruby 3.0でdb:migrateできない
- Ruby 3:Sorceryが原因で落ちる
- Ruby3:AppStatusのテストが落ちる
- bootstrap3-datetimepicker-railsの代替品を使う
- コントローラ・アクションとビューが対応しない場合にJavaScriptが動作しない HOT 1
- Rack アプリケーションサーバを Unicorn から Puma へ移行する
- 期間指定検索:メッセージのフィルタ機能を追加する HOT 1
- 「現在の状態」ページに稼働時間が正確に表示されない HOT 3
- JavaScriptのCookie操作ライブラリを移行する HOT 2
- npmパッケージのchart.jsを使う
- JavaScriptのエントリポイントを減らす
- IRCボット:シグナルハンドラのバグ
- 管理画面:「非表示の発言」を表示できない
- Ruby 2.6以下のサポートを落とす
- mIRC 装飾とURL自動リンク化の併用
- MroongaのDockerイメージ更新が原因でテストに失敗する
- transactionを削除する
- webpacker を削除する HOT 1
- sidekiq を 7.x 系列へ更新すると、テスト個別のRedis接続情報を使用できずテストに失敗する
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log-archiver.