Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
pixivコミックで作品が公開されるってどういうこと?
Search
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
2k
Other Decks in Programming
See All in Programming
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
1.9k
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
170
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
130
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
300
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
490
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
230
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
280
不幸な GC
chencmd
0
900
スマート反転とウェブアクセシビリティ
camiha
0
180
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
KATA
mclloyd
PRO
35
15k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
410
Building an army of robots
kneath
306
46k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
830
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
280
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
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を使ってデータの取得を簡便化
ご清聴ありがとうござい ました!