Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "encoding/json"
- "fmt"
- "time"
- "github.com/timehop/jimmy/redis"
- )
- func main() {
- r := redis.NewPool("redis://<redacted>:6379", redis.DefaultConfig)
- for {
- members, err := r.SRandMember("import:drain.backlog", 10)
- if err != nil {
- panic(err)
- }
- for _, member := range members {
- var c Content
- if err := json.Unmarshal([]byte(member), &c); err != nil {
- panic(err)
- }
- // Print out the dynamo user_key and date_key
- userID := int(c.UserID)
- date := time.Unix(int64(c.At), 0).UTC()
- userKey := fmt.Sprintf("%s:%d", date.Format("02012006"), userID)
- dateKey := fmt.Sprintf("%10d:%s:%s", int64(c.At), c.ContentType, c.ContentID)
- // Print in two columns
- fmt.Printf("%-5s \t%v\n", userKey, dateKey)
- // Uncomment the below to print out the data field
- // if c.ContentType == "facebook_feed" {
- // fmt.Printf("%s", c.Data)
- // }
- }
- }
- }
- type Content struct {
- AccountID float64 `json:"account_id"`
- At float64 `json:"at"`
- ClientID string `json:"client_id"`
- ContentID string `json:"content_id"`
- ContentType string `json:"content_type"`
- Data string `json:"data"`
- Platform bool `json:"platform"`
- Uid string `json:"uid"`
- UserID float64 `json:"user_id"`
- UserPartnerID float64 `json:"user_partner_id"`
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement