Class: Feed

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/ting_model/feed.rb

Class Method Summary collapse

Class Method Details

.del_feed(uid, id, groupIDs, type = 'event') ⇒ Object

删除feed



36
37
38
39
40
41
42
43
# File 'lib/ting_model/feed.rb', line 36

def self.del_feed(uid,id,groupIDs,type='event')
  begin
    FEED_WEB.delFeeds(uid,id,type,groupIDs)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.deleteFeed(uid, feedId, groupIds, type) ⇒ Object

删除feed

Parameters:

  • uid

    用户id

  • feedId

    feed的id

  • groupIds

    分组id

  • type

    feed的类型 event|sound



100
101
102
103
104
105
106
107
# File 'lib/ting_model/feed.rb', line 100

def self.deleteFeed(uid,feedId,groupIds,type)
  begin
    FEED_WEB.deleteFeed(uid,feedId,type,groupIds)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.get_event_by_range(key, offset, limit) ⇒ Object

获取feed event的数据



67
68
69
70
71
72
73
74
# File 'lib/ting_model/feed.rb', line 67

def self.get_event_by_range(key,offset,limit)
  begin
    Yajl::Parser.parse FEED_WEB.getWebEventJsonRange(key,offset,limit)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.get_event_by_timeline(key, timeLine, page_size, type) ⇒ Object

获取feed event的数据



57
58
59
60
61
62
63
64
# File 'lib/ting_model/feed.rb', line 57

def self.get_event_by_timeline(key,timeLine,page_size,type)
  begin
    Yajl::Parser.parse FEED_WEB.getWebEventJsonTimeline(key,timeLine,page_size,type)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.get_feed(uid, current_page, page_size) ⇒ Object

现在未使用 获取feed的数据



7
8
9
10
11
12
13
14
# File 'lib/ting_model/feed.rb', line 7

def self.get_feed(uid,current_page,page_size)
  begin
    Yajl::Parser.parse FEED_WEB.getWebFeed(uid,current_page,page_size)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.get_feed_by_score(uid, timeLine, page_size, type = 0) ⇒ Object

获取feed event的数据



17
18
19
20
21
22
23
24
# File 'lib/ting_model/feed.rb', line 17

def self.get_feed_by_score(uid,timeLine,page_size,type=0)
  begin
    Yajl::Parser.parse FEED_WEB.getWebEventJson(uid,timeLine,page_size,type)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.get_feed_content_by_score(uid, timeLine, page_size, type = 0) ⇒ Object

获取feed 声音流的数据



26
27
28
29
30
31
32
33
# File 'lib/ting_model/feed.rb', line 26

def self.get_feed_content_by_score(uid,timeLine,page_size,type=0)
  begin
    Yajl::Parser.parse FEED_WEB.getContentFeedJson(uid,timeLine,page_size,type)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.get_feed_data(feed, timeLine) ⇒ Object

去除内容,仅保留分页信息的feed



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/ting_model/feed.rb', line 131

def self.get_feed_data feed,timeLine
  feedData = feed["feedData"]
  if feedData && feedData.length !=0
     timeLine = feedData[feedData.length-1]['timeLine']
     feed.store("timeLine",timeLine)
  end
  feed.delete "feedData"
 if feed['timeLine'].nil?
    feed['timeLine']=timeLine
  end

  feed.to_json
end

.get_feed_uids(feed) ⇒ Object

组装所有的用户信息



145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/ting_model/feed.rb', line 145

def self.get_feed_uids feed
  feedData = feed["feedData"]
  uids = Array.new
  if feedData && feedData.length !=0
     feedData.each do |f|
 #判断转发
 if f['type'] && f['type']=='fts'
	uids.push(f['toUid'])
 end
       uids.push(f['uid'])
     end
  end
  uids.uniq
end

.get_play_list(uid, page_size) ⇒ Object

现在未使用 获得feed的播放列表



122
123
124
125
126
127
128
129
# File 'lib/ting_model/feed.rb', line 122

def self.get_play_list uid,page_size
  begin
    FEED_WEB.getContentList(uid,page_size)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.get_track_by_range(key, offset, limit) ⇒ Object

获取feed event的数据



87
88
89
90
91
92
93
94
# File 'lib/ting_model/feed.rb', line 87

def self.get_track_by_range(key,offset,limit)
  begin
    Yajl::Parser.parse FEED_WEB.getWebTrackJsonRange(key,offset,limit)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.get_track_by_timeline(key, timeLine, page_size, type) ⇒ Object

获取feed 声音流的数据



77
78
79
80
81
82
83
84
# File 'lib/ting_model/feed.rb', line 77

def self.get_track_by_timeline(key,timeLine,page_size,type)
  begin
    Yajl::Parser.parse FEED_WEB.getWebTrackJsonTimeline(key,timeLine,page_size,type)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.no_read_num(uid) ⇒ Object

获得用户未读数量



46
47
48
49
50
51
52
53
# File 'lib/ting_model/feed.rb', line 46

def self.no_read_num uid
  begin
    FEED_WEB.getAllNoReadNum(uid)
  rescue Exception => e
    logger.error e.message
    nil
  end
end

.no_read_num2(key) ⇒ Object

获得用户未读数量

Parameters:

  • key

    用户id或者用户id+分组id



111
112
113
114
115
116
117
118
# File 'lib/ting_model/feed.rb', line 111

def self.no_read_num2 key
  begin
    FEED_WEB.getWebUnreadNumJson(key)
  rescue Exception => e
    logger.error e.message
    nil
  end
end