Skip to content

Instantly share code, notes, and snippets.

@servidorv
Created November 9, 2012 16:22
Show Gist options
  • Save servidorv/4046634 to your computer and use it in GitHub Desktop.
Save servidorv/4046634 to your computer and use it in GitHub Desktop.
compact key
def get_loyalty(date_range, page_id)
loyalty_users = {}
date_range.each{|range|
loyalty_users.merge!([range[:month], range[:year]] => find_loyaltys(range[:month], range[:year], page_id))
}
return loyalty_users
end
this comes out like
users_loyalty: {
[8, 2012]: [ ],
[9, 2012]: [ ],
[10, 2012]: [
{
_id: {
$oid: "509d2256844d8b1810000019"
},
name: "Baso car",
category: "Automobiles and parts",
id: "276256145729599",
month: 10,
year: 2012,
page_id: "58128939954"
},
i want it to be like
users_loyalty: {
[82012]: [ ],
[92012]: [ ],
[102012]: [
{
_id: {
$oid: "509d2256844d8b1810000019"
},
name: "Baso car",
category: "Automobiles and parts",
id: "276256145729599",
month: 10,
year: 2012,
page_id: "58128939954"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment