PageRenderTime 76ms CodeModel.GetById 39ms RepoModel.GetById 0ms app.codeStats 0ms

/webapp/_lib/dao/interface.FollowDAO.php

https://github.com/SimonCoopey/ThinkUp
PHP | 326 lines | 39 code | 0 blank | 287 comment | 0 complexity | 004955c922aeb9d1ab377108f55a8af9 MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. * ThinkUp/webapp/_lib/model/interface.FollowDAO.php
  5. *
  6. * Copyright (c) 2009-2016 Gina Trapani, Christoffer Viken
  7. *
  8. * LICENSE:
  9. *
  10. * This file is part of ThinkUp (http://thinkup.com).
  11. *
  12. * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
  13. * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
  14. * later version.
  15. *
  16. * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
  17. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18. * details.
  19. *
  20. * You should have received a copy of the GNU General Public License along with ThinkUp. If not, see
  21. * <http://www.gnu.org/licenses/>.
  22. *
  23. *
  24. * Follow Data Access Object Interface
  25. *
  26. * @license http://www.gnu.org/licenses/gpl.html
  27. * @copyright 2009-2016 Gina Trapani, Christoffer Viken
  28. * @author Gina Trapani <ginatrapani[at]gmail[dot]com>
  29. * @author Christoffer Viken <christoffer[at]viken[dot]me>
  30. */
  31. interface FollowDAO {
  32. /**
  33. * Checks whether a given 'follow' exist in storage.
  34. * @param int $user_id
  35. * @param int $follower_id
  36. * @param str $network
  37. * @param bool $is_active Whether or not relationship should be active only
  38. * @return bool true if follow exists
  39. */
  40. public function followExists($user_id, $follower_id, $network, $is_active=false);
  41. /**
  42. * Updates 'last seen' in storage.
  43. * @param int $user_id
  44. * @param int $follower_id
  45. * @param str $network
  46. * @param string $debug_api_call
  47. * @return int update count
  48. */
  49. public function update($user_id, $follower_id, $network, $debug_api_call = '');
  50. /**
  51. * Deactivates a 'follow' in storage.
  52. * @param int $user_id
  53. * @param int $follower_id
  54. * @param str $network
  55. * @param string $debug_api_call
  56. * @return int update count
  57. */
  58. public function deactivate($user_id, $follower_id, $network, $debug_api_call = '');
  59. /**
  60. * Adds a 'follow' to storage
  61. * @param int $user_id
  62. * @param int $follower_id
  63. * @param str $network
  64. * @param string $debug_api_call
  65. * @return int insert count
  66. */
  67. public function insert($user_id, $follower_id, $network, $debug_api_call = '');
  68. /**
  69. * Gets the number of follow(ers) with errors for a given user
  70. * @param int $user_id
  71. * @param str $network
  72. * @return int with the number
  73. */
  74. public function countTotalFollowsWithErrors($user_id, $network);
  75. /**
  76. * Gets the number of friends with errors for a given user.
  77. * @param int $user_id
  78. * @param str $network
  79. * @return int with the number
  80. */
  81. public function countTotalFriendsWithErrors($user_id, $network);
  82. /**
  83. * Gets the number of follows that have full datails.
  84. * @param int $user_id
  85. * @param str $network
  86. * @return int with the number
  87. */
  88. public function countTotalFollowsWithFullDetails($user_id, $network);
  89. /**
  90. * Gets the number of follows that are protected.
  91. * Includes inactive friendships in count.
  92. * @param int $user_id
  93. * @param str $network
  94. * @return int with the number
  95. */
  96. public function countTotalFollowsProtected($user_id, $network);
  97. /**
  98. * Count the total number of friends in storage related to a user.
  99. * Originally counts all the friends, also the inactive ones,
  100. * this may be a subject to change.
  101. * @param int $user_id
  102. * @param str $network
  103. * @return int with the number
  104. */
  105. public function countTotalFriends($user_id, $network);
  106. /**
  107. * Gets the number of friends of a user that joined the network after the specified date
  108. * @param int $user_id
  109. * @param str $network
  110. * @param str $date Fetch friends joined after this date
  111. * @return int Number of friends that joined after date
  112. */
  113. public function countTotalFriendsJoinedAfterDate($user_id, $network, $date);
  114. /**
  115. * Gets the number of friends that are protected.
  116. * Includes inactive friendships in count.
  117. * @param int $user_id
  118. * @param str $network
  119. * @return int Total protected friends
  120. */
  121. public function countTotalFriendsProtected($user_id, $network);
  122. /**
  123. * Get a list of followers without details in storage.
  124. * @param int $user_id
  125. * @param str $network
  126. * @return array Numbered keys, with arrays - named keys
  127. */
  128. public function getUnloadedFollowerDetails($user_id, $network);
  129. /**
  130. * Get a list of friends without details in storage.
  131. * @param int $user_id
  132. * @param str $network
  133. * @return array Numbered keys, with arrays - named keys
  134. */
  135. public function getUnloadedFriendDetails($user_id, $network);
  136. /**
  137. * Get the friends updated the longest time ago, if age is more than a given number of days ago.
  138. * @param int $user_id
  139. * @param str $network
  140. * @param int $number_days_old Default 2
  141. * @param int $limit Number to return, default 10
  142. * @return arr User objects
  143. */
  144. public function getStalestFriends($user_id, $network, $number_days_old=2, $limit=10);
  145. /**
  146. * Gets the person in storage seen the longest time ago.
  147. * @param str $network
  148. * @return array Named keys
  149. */
  150. public function getOldestFollow($network);
  151. /**
  152. * Gets the person in storage the user follows, where the follow was seen the longest time ago.
  153. * @param str $user_id
  154. * @param str $network
  155. * @return array Named keys
  156. */
  157. public function getOldestFriend($user_id, $network);
  158. /**
  159. * Gets the followers with most followers.
  160. * @param int $user_id
  161. * @param str $network
  162. * @param int $count
  163. * @return array Numbered keys, with arrays - named keys
  164. */
  165. public function getMostFollowedFollowers($user_id, $network, $count = 20, $page = 1);
  166. /**
  167. * Gets the followers with highest follower:friend count.
  168. * @param int $user_id
  169. * @param str $network
  170. * @param int $count
  171. * @param int $page defaults to 1
  172. * @return array - numbered keys, with arrays - named keys
  173. */
  174. public function getLeastLikelyFollowers($user_id, $network, $count = 20, $page = 1);
  175. /**
  176. * Gets the followers with highest follower:friend count first seen by ThinkUp in the past 7 days.
  177. * @param int $user_id
  178. * @param str $network
  179. * @param int $count
  180. * @param int $page defaults to 1
  181. * @return array - numbered keys, with arrays - named keys
  182. */
  183. public function getLeastLikelyFollowersThisWeek($user_id, $network, $count = 20, $page = 1);
  184. /**
  185. * Gets the followers who are verified by the network first seen by ThinkUp a specified number of days ago.
  186. * @param str $user_id
  187. * @param str $network
  188. * @param int $days_ago
  189. * @param int $limit
  190. * @return array - numbered keys, with arrays - named keys
  191. */
  192. public function getVerifiedFollowersByDay($user_id, $network, $days_ago=0, $limit=10);
  193. /**
  194. * Gets the followers from a location by the network first seen by ThinkUp a specified number of days ago.
  195. * @param str $user_id
  196. * @param str $network
  197. * @param str $location
  198. * @param int $days_ago
  199. * @param int $limit
  200. **/
  201. public function getFollowersFromLocationByDay($user_id, $network, $location, $days_ago=0, $limit=10);
  202. /**
  203. * Gets the followers with the earliest join date.
  204. * @param int $user_id
  205. * @param str $network
  206. * @param int $count
  207. * @param int $page defaults to 1
  208. * @return array - numbered keys, with arrays - named keys
  209. */
  210. public function getEarliestJoinerFollowers($user_id, $network, $count = 20, $page = 1);
  211. /**
  212. * Gets the friends with the highest tweet per day count.
  213. * @param int $user_id
  214. * @param str $network
  215. * @param int $count
  216. * @param int $page defaults to 1
  217. * @return array - numbered keys, with arrays - named keys
  218. */
  219. public function getMostActiveFollowees($user_id, $network, $count = 20, $page = 1);
  220. /**
  221. * Gets a list of inactive friends.
  222. * @param int $user_id
  223. * @param str $network
  224. * @param int $count
  225. * @param int $page defaults to 1
  226. * @return array - numbered keys, with arrays - named keys
  227. */
  228. public function getFormerFollowees($user_id, $network, $count = 20, $page = 1);
  229. /**
  230. * Gets a list of inactive followers.
  231. * @param int $user_id
  232. * @param str $network
  233. * @param int $count
  234. * @param int $page defaults to 1
  235. * @return array - numbered keys, with arrays - named keys
  236. */
  237. public function getFormerFollowers($user_id, $network, $count = 20, $page = 1);
  238. /**
  239. * Gets the followers with the lowest tweet-per-day ratio.
  240. * @param int $user_id
  241. * @param str $network
  242. * @param int $count
  243. * @param int $page defaults to 1
  244. * @return array - numbered keys, with arrays - named keys
  245. */
  246. public function getLeastActiveFollowees($user_id, $network, $count = 20, $page = 1);
  247. /**
  248. * Gets the friends with the most followers
  249. * @param int $user_id
  250. * @param str $network
  251. * @param int $count
  252. * @param int $page defaults to 1
  253. * @return array - numbered keys, with arrays - named keys
  254. */
  255. public function getMostFollowedFollowees($user_id, $network, $count = 20, $page = 1);
  256. /**
  257. * Gets friends that the two inputed user IDs both follow.
  258. * @param int $uid
  259. * @param int $instance_uid
  260. * @param str $network
  261. * @param int $page defaults to 1
  262. * @return array - numbered keys, with arrays - named keys
  263. */
  264. public function getMutualFriends($uid, $instance_uid, $network);
  265. /**
  266. * Gets the friends that do not follow you back.
  267. * @param int $uid
  268. * @param str $network
  269. * @return array - numbered keys, with arrays - named keys
  270. */
  271. public function getFriendsNotFollowingBack($uid, $network);
  272. /**
  273. * Gets the people you follow and replied to on this week, a year ago.
  274. * @param int $user_id
  275. * @param str $network
  276. * @return array - numbered keys, with arrays - named keys
  277. */
  278. public function getFolloweesRepliedToThisWeekLastYear($user_id, $network);
  279. /**
  280. * Search a user's followers names and bio. (Use name:term to search only name field.)
  281. * @param arr $keywords
  282. * @param str $network
  283. * @param str $user_id
  284. * @param int $page_number
  285. * @param int $page_count
  286. */
  287. public function searchFollowers(array $keywords, $network, $user_id, $page_number=1, $page_count=20);
  288. /**
  289. * Gets the followers that joined just before user
  290. * @param str $user_id
  291. * @param str $network
  292. * @param str $earliest_date Earliest date a friend should have joined to be returned
  293. * @param str $latest_date Latest date a friend should have joined to be returned
  294. * @return array Array of User objects
  295. **/
  296. public function getFriendsJoinedInTimeFrame($user_id, $network, $earliest_date, $latest_date);
  297. /**
  298. * Gets the followers who are verified by the network, order by follower count descending
  299. * @param str $user_id
  300. * @param str $network
  301. * @param int $limit
  302. * @return array - numbered keys, with arrays - named keys
  303. */
  304. public function getVerifiedFollowers($user_id, $network, $limit=20);
  305. /**
  306. * Gets the count of followers who are verified by the network
  307. * @param str $user_id
  308. * @param str $network
  309. * @return int number of verified followers
  310. */
  311. public function getVerifiedFollowerCount($user_id, $network);
  312. /**
  313. * Find the median follower count of people a user follows
  314. * @param str $user_id
  315. * @param str $network
  316. * @return float average follower count
  317. */
  318. public function getMedianFollowerCountOfFriends($user_id, $network);
  319. /**
  320. * Find out how many people a user follows have fewer followers
  321. * @param str $user_id
  322. * @param str $network
  323. * @return float average follower count
  324. */
  325. public function getCountOfFriendsWithFewerFollowers($user_id, $network, $followers);
  326. }