Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
pixivコミックで作品が公開されるってどういうこと?
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
imadoki
October 05, 2023
Programming
1.6k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
pixivコミックで作品が公開されるってどういうこと?
PIXIV MEETUP2023のLTで発表した際の資料です
imadoki
October 05, 2023
More Decks by imadoki
See All by imadoki
Multiple Databasesを用いて2つのRailsプロジェクトを統合する
imadoki
1
1.9k
Other Decks in Programming
See All in Programming
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
510
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
OSもどきOS
arkw
0
560
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
540
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
240
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
130
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
200
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
480
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
240
Lessons from Spec-Driven Development
simas
PRO
0
190
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
110
Featured
See All Featured
The SEO identity crisis: Don't let AI make you average
varn
0
490
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
The Pragmatic Product Professional
lauravandoore
37
7.3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
280
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Optimizing for Happiness
mojombo
378
71k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
GitHub's CSS Performance
jonrohan
1033
470k
Technical Leadership for Architectural Decision Making
baasie
3
410
Transcript
pixiv Inc. pixivコミックで作品が公開 されるってどういうこと? @ikumin
Profile ikumin エンジニア 2016年入社 コミック事業部 pixivコミック部 業務では主にバックエンドを担当し ていてRailsを書いています
• 2012年から始まったマンガ サービス • ブラウザ/Android/iOS • 商業作品の連載 • 電子書籍の販売 •
pixivに投稿された作品の閲覧
• 期間中、無料で何度も読める • 購入すると読める 連載エピソードの形態
エピソードの公開設定
基本のデータ
エピソードの公開設定 • 公開期間 • 種類 • (種類によっては)価格
エピソードの公開設定 # 公開設定 class PublishingSetting < ApplicationRecord ## typeによってどの公開設定化を判別する def
free? type == 'PublishingSetting::Free' end def sell? type == 'PublishingSetting::Sell' end end
全話開放キャンペーン
公開中のエピソードを取得するには • 各種公開フラグがONかどうか? • 期間内の公開設定はあるか? • 全話開放キャンペーン対象かどうか? を確認する必要がある
普通にやってみる SELECT `stories`.* FROM `stories` INNER JOIN `works` `work` ON
`work`.`id` = `stories`.`work_id` INNER JOIN `magazines` `magazine` ON `magazine`.`id` = `work`.`magazine_id` INNER JOIN `publish_all_story_campaign_works` ON `publish_all_story_campaign_works`.`work_id` = `work`.`id` INNER JOIN `publishing_settings` ON `publishing_settings`.`story_id` = `stories`.`id` WHERE `work`.`is_public` = 1 AND `magazine`.`is_public` = 1 AND ( (`publishing_settings`.`start_at` <= :now) AND (`publishing_settings`.`finish_at` < :now OR `publishing_settings`.`finish_at` IS NULL) OR `publish_all_story_campaigns`.`approved` = 1 )
他にも… • レーティングの問題でアプリでは表示できない作品がある • 販売中のエピソードをは購入しなければ読めない • 公開中の作品の最新話を取得したい • 最新話の公開日順に作品を並べ替えたい
• 公開中のエピソードへの関連と 最新話の公開日を持つキャッ シュ代わりのテーブルを用意 • 毎日12時に更新 キャッシュテーブルの用意
• 一括で取得した情報をモデルのインスタンスに紐づけて くれるgem • https://github.com/walf443/bulk_loader BulkLoaderの利用
購入情報を一括で取得する class Story < ApplicationRecord #... bulk_loader, :purchased? do |ids,
user_id| next {} if user_id.nil? # APIで購入の有無を問い合わせ purchased_story_ids = Store::App::OrderedEpisodes.get(user_id, ids) # {id => purchased?} という形式のHashに変換 ids.index_with {|id| purchased_story_ids.include?(id) } end end
購入情報を一括で取得する # ログインユーザーがstoriesを購入しているかどうかを調べる Story.bulk_loader.load(:purchased?, stories, current_user) stories.each do |story| story.purchased?
# bulk_loaderでAPIから取得したエピソードごとの購入 有無を引ける end
• エピソードが購入済みか • エピソードが無料公開中か • エピソードが販売中か • 作品が全話開放キャンペーン中か これを利用して
まとめ • 複雑な要件に対応するため、いろんなところに公開に関 わるデータが散らばっている • 複数のテーブルに絡んだ条件をキャッシュして緩和 • BulkLoaderを使ってデータの取得を簡便化
ご清聴ありがとうござい ました!