Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. DROP FUNCTION IF EXISTS user_repo //
  2. CREATE FUNCTION user_repo(user_id INT) RETURNS VARCHAR(20)
  3. BEGIN
  4. DECLARE vote_value mediumint;
  5. DECLARE score mediumint;
  6.  
  7. SELECT coalesce(sum(r.vote_value), 0), coalesce(sum(r.score), 0)
  8. INTO vote_value, score
  9. FROM reputations
  10. WHERE owner_id = user_id
  11. AND date_time > unix_timestamp(DATE_SUB(now(), INTERVAL 1 WEEK));
  12.  
  13. RETURN CONCAT_WS(',', vote_value, score);
  14. END;//
  15.  
  16. DROP FUNCTION IF EXISTS user_repo //
  17. CREATE FUNCTION user_repo(user_id INT, range VARCHAR(10)) RETURNS VARCHAR(20)
  18. BEGIN
  19. DECLARE vote_value mediumint;
  20. DECLARE score mediumint;
  21.  
  22. SELECT coalesce(sum(r.vote_value), 0), coalesce(sum(r.score), 0)
  23. INTO vote_value, score
  24. FROM reputations
  25. WHERE owner_id = user_id
  26. AND date_time > unix_timestamp(DATE_SUB(now(), INTERVAL 1 range));
  27.  
  28. RETURN CONCAT_WS(',', vote_value, score);
  29. END;//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement