Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Map Re-reduce
Started POST "/reports/distributor" for 127.0.0.1 at 2013-03-19 20:28:49 +0530
Processing by ReportsController#distributor as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"0auleqI26KHq7LL373WpzslaGJWy45LMhnPeEpWedoc=", "search"=>{"project_id"=>"5139f91fb9b67dbe3a000004", "distributor_id"=>"", "start_date"=>"07/03/2013 - 00:00 AM", "end_date"=>"19/03/2013 - 23:59 PM"}, "commit"=>"Search"}
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (0.7286ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=users selector={"$query"=>{"_id"=>"513f0f9db9b67d884a000002"}, "$orderby"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil (0.5398ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=organisations selector={"$query"=>{"_id"=>"5139f184b9b67d8e73000001"}, "$orderby"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil (0.4199ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=projects selector={"deleted_at"=>nil, "status"=>{"$ne"=>"New"}} flags=[] limit=0 skip=0 batch_size=nil fields=nil (0.8392ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=distributors selector={"deleted_at"=>nil, "$and"=>[{"_id"=>{"$in"=>["513c8a70b9b67d35e000000b", "513d6576b9b67dfc6f000044", "513d7874b9b67d94bb00000e", "513d7a52b9b67d94bb000020", "513d7aecb9b67d94bb000023", "513d7d84b9b67d94bb000035", "513d7e38b9b67d94bb000039", "513d7ee9b9b67d94bb00003e", "513d7fcab9b67d94bb000049", "513d80c9b9b67d94bb000058", "513d81c5b9b67dca4c000005", "513d8254b9b67d94bb000063", "513d8307b9b67dca4c00000c", "513d83f2b9b67d94bb00006d", "513d8491b9b67dca4c00000f", "513d84f6b9b67dca4c000018", "513dabf9b9b67d37ca00000d", "513dac88b9b67d37ca000011", "513dacecb9b67d37ca000018", "513dad59b9b67d37ca00001c", "513dadb6b9b67d37ca000020", "513dadffb9b67d37ca000022", "513dae62b9b67d9ecd00000a", "513daefdb9b67d9ecd00000f", "513daf88b9b67d37ca000024", "513db355b9b67d37ca000042", "513db3b2b9b67d37ca000045", "513db3d7b9b67d37ca000047", "513db3f6b9b67d37ca000048", "513db444b9b67d37ca00004b", "513db46fb9b67d37ca00004c", "513db49fb9b67d37ca00004d", "513db4e3b9b67d37ca00004f", "513db50ab9b67d37ca000050", "513db532b9b67d9ecd000013", "513db55eb9b67d9ecd000016", "513db5a3b9b67d9ecd00001a", "513db5cbb9b67d9ecd00001b", "513db5f7b9b67d9ecd00001c", "514021ddb9b67d8ac400000f", "514055a4b9b67db29c000012", "51405742b9b67dab23000009", "514057b9b9b67db29c000018", "514057fcb9b67dab2300000d", "51405834b9b67dab2300000f", "51405b8ab9b67dab23000018", "51405bd2b9b67dab2300001a", "51405c1ab9b67d65bb000002", "51405c66b9b67dab23000020", "51405ca4b9b67dab23000025", "51405de5b9b67d65bb00000a", "51406678b9b67d9114000001", "514066b4b9b67d9114000003", "514066f2b9b67de614000001", "5140677bb9b67de614000004", "51406810b9b67de614000008", "51406873b9b67d9114000005", "514068cbb9b67d9114000008", "5140690cb9b67d911400000a", "51406921b9b67d911400000c", "51415f62b9b67de54900000a", "51415fb4b9b67de549000012", "5141a65eb9b67db4e6000009", "5141b006b9b67d37eb000005", "5141b067b9b67d1e46000036", "5141b0a9b9b67d1e4600003b", "5141c1beb9b67dea43000054", "5141c399b9b67d37eb000039", "51429762b9b67db54e000011", "514297fab9b67db54e00001f", "5142987fb9b67db54e000025", "5142bd08b9b67db499000124", "5142c046b9b67dc5c4000140", "5142c6a8b9b67dbfc8000015", "51431e6cb9b67dc48400000f", "51431e96b9b67dc484000010", "51431eb5b9b67dc484000011", "51431ed1b9b67dc484000014", "51431f1fb9b67d7781000001"]}}]} flags=[] limit=0 skip=0 batch_size=nil fields=nil (12.9914ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=projects selector={"deleted_at"=>nil, "_id"=>"5139f91fb9b67dbe3a000004"} flags=[] limit=0 skip=0 batch_size=nil fields=nil (0.8907ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=unit_sizes selector={"deleted_at"=>nil, "project_id"=>"5139f91fb9b67dbe3a000004"} flags=[] limit=0 skip=0 batch_size=nil fields=nil (0.6809ms)
MOPED: 127.0.0.1:27017 COMMAND database=phalcomm_production command={:mapreduce=>"bookings", :map=>"function() {\n if (this.is_cancelled == false) {\n data = { bookings: [ this._id ],\n booking_amount: this.booking_amount, \n amt_cleared: this.paid_amount,\n cancellations: 0,\n unit_sizes: {}\n }\n data.unit_sizes[this.unit_size_id.str] = 1;\n emit(this.resource_id, data);\n } else {\n emit(this.resource_id, { cancellations: 1 });\n }\n };\n ", :reduce=>"function(key, values) {\n var r = { bookings: [], booking_amount: 0, amt_cleared: 0, amt_received: 0, cancellations: 0, unit_sizes: {} }\n values.forEach(function(value) {\n if (value.booking_amount) { r.booking_amount += value.booking_amount; }\n if (value.amt_cleared) { r.amt_cleared += value.amt_cleared }\n if (value.amt_received) { r.amt_received += value.amt_received }\n if (value.cancellations) { r.cancellations += value.cancellations }\n \n for(unit_size_id in value.unit_sizes) {\n if (r.unit_sizes[unit_size_id]) {\n r.unit_sizes[unit_size_id] += value.unit_sizes[unit_size_id]\n }\n else {\n r.unit_sizes[unit_size_id] = value.unit_sizes[unit_size_id]\n }\n }\n \n if(value.bookings && value.bookings.length > 0) {\n r.bookings = r.bookings.concat(value.bookings);\n }\n });\n return r;\n };\n ", :query=>{"deleted_at"=>nil, "project_id"=>"5139f91fb9b67dbe3a000004", "created_at"=>{"$gte"=>2013-03-06 18:30:00 UTC, "$lte"=>2013-03-18 18:30:00 UTC}, "resource_type"=>"Distributor"}, :out=>{:replace=>"distributorReport"}} (34.4181ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=distributorReport selector={} flags=[] limit=0 skip=0 batch_size=nil fields=nil (1.0238ms)
MOPED: 127.0.0.1:27017 COMMAND database=phalcomm_production command={:mapreduce=>"distributorReport", :map=>"function() {\n emit('booking_ids', { bookings: this.value.bookings });\n }\n ", :reduce=>"function(key, values) {\n r = { bookings: [] }\n values.forEach(function(value) {\n r.bookings = r.bookings.concat(value.bookings);\n });\n return r;\n }\n ", :out=>{:replace=>"tmpBookings"}} (5.9314ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=tmpBookings selector={} flags=[] limit=-1 skip=0 batch_size=nil fields=nil (0.4647ms)
MOPED: 127.0.0.1:27017 COMMAND database=phalcomm_production command={:mapreduce=>"vouchers", :map=>"function() {\n emit(this.resource_id, { amt_received: this.credit_amount } );\n }\n ", :reduce=>"function(key, values) {\n var r = { bookings: [], booking_amount: 0, amt_cleared: 0, amt_received: 0, cancellations: 0, unit_sizes: {} }\n values.forEach(function(value) {\n if (value.booking_amount) { r.booking_amount += value.booking_amount; }\n if (value.amt_cleared) { r.amt_cleared += value.amt_cleared }\n if (value.amt_received) { r.amt_received += value.amt_received }\n if (value.cancellations) { r.cancellations += value.cancellations }\n \n for(unit_size_id in value.unit_sizes) {\n if (r.unit_sizes[unit_size_id]) {\n r.unit_sizes[unit_size_id] += value.unit_sizes[unit_size_id]\n }\n else {\n r.unit_sizes[unit_size_id] = value.unit_sizes[unit_size_id]\n }\n }\n \n if(value.bookings && value.bookings.length > 0) {\n r.bookings = r.bookings.concat(value.bookings);\n }\n });\n return r;\n };\n ", :query=>{"deleted_at"=>nil, "resource_type"=>"Distributor", "booking_id"=>{"$in"=>["51430f15b9b67d6a65000064", "5143116eb9b67dba5800005e", "51431473b9b67dba580000c6", "514400a7b9b67dc101000014", "514589eab9b67dd641000047", "5146da1cb9b67d8ee7000020", "5142f253b9b67df4e7000021", "51431026b9b67d6a6500007c", "51433e35b9b67d4b6b000003", "51444429b9b67de8ad000077", "51444f22b9b67df6d8000064", "514573cbb9b67dc3e9000001", "51458804b9b67dd641000028", "51458a76b9b67d0aa700002a", "51458b9bb9b67dd64100007d", "5146cc2cb9b67d635c00001b", "5145c7a3b9b67da0a8000055", "514722adb9b67d9f9b000083", "51441866b9b67dad8c00009c", "51441b1db9b67d8c6300004b", "5145e451b9b67d105f000002", "51457c76b9b67de3db000015", "5141e6cbb9b67da67100001f", "5141ecbbb9b67d8ef8000080", "5142b816b9b67db4990000cd", "5142c842b9b67dbfc8000027", "5142d7c4b9b67d2e4f000043", "5142f838b9b67d2fa1000020", "51430d8db9b67d6a65000019", "51430f36b9b67dba58000043", "51432b2fb9b67d1b7b000005", "51444dd1b9b67d2223000065", "51457a83b9b67dc3e900003e", "51457c76b9b67de3db000014", "51457dccb9b67de3db00004b", "51458877b9b67d0aa7000003", "5145a133b9b67d983b000001", "5145c085b9b67da0a800000a", "5145d682b9b67ddf81000026", "5145f7fbb9b67d105f000023", "5146ad2eb9b67db3cb00009e", "5146d274b9b67de72e00004e", "5147027cb9b67da4e8000004", "5147027cb9b67da4e8000005", "5147078db9b67da4e8000035", "5145b557b9b67d7437000071", "51473152b9b67d9f9b0000c9", "5144243db9b67d59de000015", "5146b921b9b67d36d00000fd", "51471d73b9b67d9f9b000061", "5141bf94b9b67dea4300002c", "5141c21ab9b67dea43000055", "5143319db9b67d69e500000f", "5145c3eab9b67d53a200000b", "5145c480b9b67d53a2000029", "5146ee53b9b67d8d6a000034", "5146f0d6b9b67d6ec4000017", "5141b852b9b67d6f9e000028", "5141b920b9b67d6f9e00004d", "5141fef1b9b67de8e200002e", "5141fef1b9b67de8e200002f", "51420362b9b67de8e2000068", "51420362b9b67de8e2000069", "5142899eb9b67d578f000006", "5142a8b6b9b67dc5c4000076", "5142bb39b9b67dc5c4000114", "51443da1b9b67d2190000047", "514450b5b9b67df6d8000098", "51445547b9b67df6d80000c9", "5145ac0db9b67d7437000036", "51470bdbb9b67da4e800005a", "5143020ab9b67d2fa1000085", "5143020ab9b67d2fa1000086", "5143020ab9b67defa6000060", "51430f07b9b67d6a65000050", "514312f2b9b67dba58000088", "5143142ab9b67dba580000ad", "5143382db9b67d0e46000020", "51433987b9b67d0e46000047", "514316e8b9b67d466d000005", "51431779b9b67dba580000f3", "51431a91b9b67dba5800011b", "51431b2eb9b67dba58000142", "51433785b9b67d0e46000001", "5141c978b9b67dfd8a000002", "5142bb2eb9b67dc5c4000100", "5142e897b9b67d5a9100005d", "51443fafb9b67de8ad00003c", "5146df0cb9b67d3a1c000040", "51441c88b9b67d8c6300006e", "51453993b9b67d956700000f", "51456abdb9b67dafde000007", "5145702eb9b67dafde000041", "51459331b9b67d0aa7000058", "51459373b9b67d0aa7000075", "51471422b9b67d9f9b000004", "51471695b9b67d9f9b000030", "5145f976b9b67d105f00003f"]}}, :out=>{:reduce=>"distributorReport"}} (24.9085ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=distributorReport selector={} flags=[] limit=0 skip=0 batch_size=nil fields=nil (1.7910ms)
MOPED: 127.0.0.1:27017 COMMAND database=phalcomm_production command={:count=>"unit_sizes", :query=>{"deleted_at"=>nil, "project_id"=>"5139f91fb9b67dbe3a000004"}} (0.6022ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=distributors selector={"deleted_at"=>nil, "$and"=>[{"_id"=>{"$in"=>["513c8a70b9b67d35e000000b", "513d6576b9b67dfc6f000044", "513d7874b9b67d94bb00000e", "513d7a52b9b67d94bb000020", "513d7aecb9b67d94bb000023", "513d7d84b9b67d94bb000035", "513d7e38b9b67d94bb000039", "513d7ee9b9b67d94bb00003e", "513d7fcab9b67d94bb000049", "513d80c9b9b67d94bb000058", "513d81c5b9b67dca4c000005", "513d8254b9b67d94bb000063", "513d8307b9b67dca4c00000c", "513d83f2b9b67d94bb00006d", "513d8491b9b67dca4c00000f", "513d84f6b9b67dca4c000018", "513dabf9b9b67d37ca00000d", "513dac88b9b67d37ca000011", "513dacecb9b67d37ca000018", "513dad59b9b67d37ca00001c", "513dadb6b9b67d37ca000020", "513dadffb9b67d37ca000022", "513dae62b9b67d9ecd00000a", "513daefdb9b67d9ecd00000f", "513daf88b9b67d37ca000024", "513db355b9b67d37ca000042", "513db3b2b9b67d37ca000045", "513db3d7b9b67d37ca000047", "513db3f6b9b67d37ca000048", "513db444b9b67d37ca00004b", "513db46fb9b67d37ca00004c", "513db49fb9b67d37ca00004d", "513db4e3b9b67d37ca00004f", "513db50ab9b67d37ca000050", "513db532b9b67d9ecd000013", "513db55eb9b67d9ecd000016", "513db5a3b9b67d9ecd00001a", "513db5cbb9b67d9ecd00001b", "513db5f7b9b67d9ecd00001c", "514021ddb9b67d8ac400000f", "514055a4b9b67db29c000012", "51405742b9b67dab23000009", "514057b9b9b67db29c000018", "514057fcb9b67dab2300000d", "51405834b9b67dab2300000f", "51405b8ab9b67dab23000018", "51405bd2b9b67dab2300001a", "51405c1ab9b67d65bb000002", "51405c66b9b67dab23000020", "51405ca4b9b67dab23000025", "51405de5b9b67d65bb00000a", "51406678b9b67d9114000001", "514066b4b9b67d9114000003", "514066f2b9b67de614000001", "5140677bb9b67de614000004", "51406810b9b67de614000008", "51406873b9b67d9114000005", "514068cbb9b67d9114000008", "5140690cb9b67d911400000a", "51406921b9b67d911400000c", "51415f62b9b67de54900000a", "51415fb4b9b67de549000012", "5141a65eb9b67db4e6000009", "5141b006b9b67d37eb000005", "5141b067b9b67d1e46000036", "5141b0a9b9b67d1e4600003b", "5141c1beb9b67dea43000054", "5141c399b9b67d37eb000039", "51429762b9b67db54e000011", "514297fab9b67db54e00001f", "5142987fb9b67db54e000025", "5142bd08b9b67db499000124", "5142c046b9b67dc5c4000140", "5142c6a8b9b67dbfc8000015", "51431e6cb9b67dc48400000f", "51431e96b9b67dc484000010", "51431eb5b9b67dc484000011", "51431ed1b9b67dc484000014", "51431f1fb9b67d7781000001"]}}]} flags=[] limit=0 skip=0 batch_size=nil fields=nil (13.1705ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=projects selector={"deleted_at"=>nil, "status"=>{"$ne"=>"New"}} flags=[] limit=0 skip=0 batch_size=nil fields=nil (0.9227ms)
Rendered reports/_search.html.haml (323.4ms)
Rendered reports/distributor.html.haml within layouts/application (333.9ms)
MOPED: 127.0.0.1:27017 QUERY database=phalcomm_production collection=roles selector={"$query"=>{"_id"=>"5139f184b9b67d8e73000002"}, "$orderby"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil (0.7246ms)
Rendered shared/_sidebar.html.haml (296.4ms)
Rendered shared/_messages.html.haml (1.7ms)
Completed 200 OK in 1232ms (Views: 905.5ms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.