Class: EricWeixin::MediaArticle
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- EricWeixin::MediaArticle
- Defined in:
- app/models/eric_weixin/media_article.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.common_query(options) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/models/eric_weixin/media_article.rb', line 37 def self.common_query articles = self.all articles = articles.where(public_account_id: [:public_account_id]) unless [:public_account_id].blank? articles = articles.where("weixin_media_articles.tag like ?", "%#{[:tag]}%") unless [:tag].blank? unless [:start_date].blank? start_date = [:start_date].to_time start_date = start_date.change(hour: 0, min:0, sec:0) articles = articles.where("weixin_media_articles.created_at >= ?", start_date) end unless [:end_date].blank? end_date = [:end_date].to_time end_date = end_date.change(hour: 23, min:59, sec:59) articles = articles.where("weixin_media_articles.created_at <= ?", end_date) end articles end |
.create_media_article(options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/eric_weixin/media_article.rb', line 15 def self.create_media_article = , [:tag, :thumb_media_id, :author, :title, :digest, :show_cover_pic, :is_first_article, :content, :content_source_url, :public_account_id], show_cover_pic: true, is_first_article: false transaction do media_article = ::EricWeixin::MediaArticle.new media_article.save! media_article end end |
Instance Method Details
#update_media_article(options) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/models/eric_weixin/media_article.rb', line 27 def update_media_article = EricWeixin::MediaArticle. , [:tag, :thumb_media_id, :author, :title, :digest, :show_cover_pic, :is_first_article, :content, :content_source_url, :public_account_id] EricWeixin::MediaArticle.transaction do self.update! self end end |