Advertisement
Guest User

Untitled

a guest
May 27th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "encoding/json"
  5. "fmt"
  6. "time"
  7.  
  8. "github.com/timehop/jimmy/redis"
  9. )
  10.  
  11. func main() {
  12. r := redis.NewPool("redis://<redacted>:6379", redis.DefaultConfig)
  13. for {
  14. members, err := r.SRandMember("import:drain.backlog", 10)
  15. if err != nil {
  16. panic(err)
  17. }
  18. for _, member := range members {
  19. var c Content
  20. if err := json.Unmarshal([]byte(member), &c); err != nil {
  21. panic(err)
  22. }
  23.  
  24. // Print out the dynamo user_key and date_key
  25. userID := int(c.UserID)
  26. date := time.Unix(int64(c.At), 0).UTC()
  27. userKey := fmt.Sprintf("%s:%d", date.Format("02012006"), userID)
  28. dateKey := fmt.Sprintf("%10d:%s:%s", int64(c.At), c.ContentType, c.ContentID)
  29. // Print in two columns
  30. fmt.Printf("%-5s \t%v\n", userKey, dateKey)
  31.  
  32. // Uncomment the below to print out the data field
  33. // if c.ContentType == "facebook_feed" {
  34. // fmt.Printf("%s", c.Data)
  35. // }
  36. }
  37. }
  38. }
  39.  
  40. type Content struct {
  41. AccountID float64 `json:"account_id"`
  42. At float64 `json:"at"`
  43. ClientID string `json:"client_id"`
  44. ContentID string `json:"content_id"`
  45. ContentType string `json:"content_type"`
  46. Data string `json:"data"`
  47. Platform bool `json:"platform"`
  48. Uid string `json:"uid"`
  49. UserID float64 `json:"user_id"`
  50. UserPartnerID float64 `json:"user_partner_id"`
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement