@@ -32,75 +32,77 @@ Promise.all([plugins.dbConnection("countly"), plugins.dbConnection("countly_dril
3232 countlyDb . close ( ) ;
3333 console . log ( "Error occured:" , error ) ;
3434 }
35- var cnt = 0 ;
36- results = results . filter ( collection => collection && collection . collectionName && collection . collectionName . startsWith ( "drill_events" ) ) ;
37- async . eachSeries ( results , function ( collection , done ) {
38- cnt ++ ;
39- console . log ( "Processing" , cnt , "of" , results . length , collection . collectionName ) ;
40- var col = db . collection ( collection . collectionName ) ;
41- col . createIndex ( { uid : 1 } , { background : true } , function ( ) {
42- console . log ( "Done" , { uid : 1 } ) ;
43- if ( hashes [ collection . collectionName ] === "[CLY]_session" ) {
44- col . createIndex ( { ts : 1 , "up.cc" : 1 , uid : 1 } , { background : true } , function ( ) {
45- console . log ( "Done" , "[CLY]_session" , { ts : 1 , "up.cc" : 1 , uid : 1 } ) ;
46- done ( ) ;
47- } ) ;
48- }
49- else if ( hashes [ collection . collectionName ] === "[CLY]_view" ) {
50- col . createIndex ( { ts : 1 , "sg.name" : 1 } , { background : true } , function ( ) {
51- console . log ( "Done" , "[CLY]_view" , { ts : 1 , "sg.name" : 1 } ) ;
52- done ( ) ;
53- } ) ;
54- }
55- else if ( hashes [ collection . collectionName ] === "[CLY]_crash" ) {
56- col . createIndex ( { ts : 1 , "sg.crash" : 1 } , { background : true } , function ( ) {
57- console . log ( "Done" , "[CLY]_crash" , { ts : 1 , "sg.crash" : 1 } ) ;
58- done ( ) ;
59- } ) ;
60- }
61- else if ( hashes [ collection . collectionName ] === "[CLY]_push_action" ) {
62- col . createIndex ( { ts : 1 , "sg.i" : 1 , uid : 1 } , { background : true } , function ( ) {
63- console . log ( "Done" , "[CLY]_push_action" , { ts : 1 , "sg.i" : 1 } ) ;
64- done ( ) ;
65- } ) ;
66- }
67- else if ( hashes [ collection . collectionName ] === "[CLY]_star_rating" ) {
68- col . createIndex ( { ts : 1 , "sg.widget_id" : 1 , "sg.rating" : 1 , uid : 1 } , { background : true } , function ( ) {
69- console . log ( "Done" , "[CLY]_star_rating" , { ts : 1 , "sg.widget_id" : 1 , "sg.rating" : 1 } ) ;
70- done ( ) ;
71- } ) ;
72- }
73- else if ( hashes [ collection . collectionName ] === "[CLY]_nps" ) {
74- col . createIndex ( { ts : 1 , "sg.widget_id" : 1 , "sg.rating" : 1 , uid : 1 } , { background : true } , function ( ) {
75- console . log ( "Done" , "[CLY]_nps" , { ts : 1 , "sg.widget_id" : 1 , "sg.rating" : 1 } ) ;
76- done ( ) ;
77- } ) ;
78- }
79- else if ( hashes [ collection . collectionName ] === "[CLY]_survey" ) {
80- col . createIndex ( { ts : 1 , "sg.widget_id" : 1 , uid : 1 } , { background : true } , function ( ) {
81- console . log ( "Done" , "[CLY]_survey" , { ts : 1 , "sg.widget_id" : 1 } ) ;
82- done ( ) ;
83- } ) ;
84- }
85- else {
86- col . createIndex ( { ts : 1 } , { background : true } , function ( ) {
87- console . log ( "Done" , { ts : 1 } ) ;
35+ else {
36+ var cnt = 0 ;
37+ results = results . filter ( collection => collection && collection . collectionName && collection . collectionName . startsWith ( "drill_events" ) ) ;
38+ async . eachSeries ( results , function ( collection , done ) {
39+ cnt ++ ;
40+ console . log ( "Processing" , cnt , "of" , results . length , collection . collectionName ) ;
41+ var col = db . collection ( collection . collectionName ) ;
42+ col . createIndex ( { uid : 1 } , { background : true } , function ( ) {
43+ console . log ( "Done" , { uid : 1 } ) ;
44+ if ( hashes [ collection . collectionName ] === "[CLY]_session" ) {
45+ col . createIndex ( { ts : 1 , "up.cc" : 1 , uid : 1 } , { background : true } , function ( ) {
46+ console . log ( "Done" , "[CLY]_session" , { ts : 1 , "up.cc" : 1 , uid : 1 } ) ;
47+ done ( ) ;
48+ } ) ;
49+ }
50+ else if ( hashes [ collection . collectionName ] === "[CLY]_view" ) {
51+ col . createIndex ( { ts : 1 , "sg.name" : 1 } , { background : true } , function ( ) {
52+ console . log ( "Done" , "[CLY]_view" , { ts : 1 , "sg.name" : 1 } ) ;
53+ done ( ) ;
54+ } ) ;
55+ }
56+ else if ( hashes [ collection . collectionName ] === "[CLY]_crash" ) {
57+ col . createIndex ( { ts : 1 , "sg.crash" : 1 } , { background : true } , function ( ) {
58+ console . log ( "Done" , "[CLY]_crash" , { ts : 1 , "sg.crash" : 1 } ) ;
59+ done ( ) ;
60+ } ) ;
61+ }
62+ else if ( hashes [ collection . collectionName ] === "[CLY]_push_action" ) {
63+ col . createIndex ( { ts : 1 , "sg.i" : 1 , uid : 1 } , { background : true } , function ( ) {
64+ console . log ( "Done" , "[CLY]_push_action" , { ts : 1 , "sg.i" : 1 } ) ;
65+ done ( ) ;
66+ } ) ;
67+ }
68+ else if ( hashes [ collection . collectionName ] === "[CLY]_star_rating" ) {
69+ col . createIndex ( { ts : 1 , "sg.widget_id" : 1 , "sg.rating" : 1 , uid : 1 } , { background : true } , function ( ) {
70+ console . log ( "Done" , "[CLY]_star_rating" , { ts : 1 , "sg.widget_id" : 1 , "sg.rating" : 1 } ) ;
71+ done ( ) ;
72+ } ) ;
73+ }
74+ else if ( hashes [ collection . collectionName ] === "[CLY]_nps" ) {
75+ col . createIndex ( { ts : 1 , "sg.widget_id" : 1 , "sg.rating" : 1 , uid : 1 } , { background : true } , function ( ) {
76+ console . log ( "Done" , "[CLY]_nps" , { ts : 1 , "sg.widget_id" : 1 , "sg.rating" : 1 } ) ;
77+ done ( ) ;
78+ } ) ;
79+ }
80+ else if ( hashes [ collection . collectionName ] === "[CLY]_survey" ) {
81+ col . createIndex ( { ts : 1 , "sg.widget_id" : 1 , uid : 1 } , { background : true } , function ( ) {
82+ console . log ( "Done" , "[CLY]_survey" , { ts : 1 , "sg.widget_id" : 1 } ) ;
83+ done ( ) ;
84+ } ) ;
85+ }
86+ else {
87+ col . createIndex ( { ts : 1 } , { background : true } , function ( ) {
88+ console . log ( "Done" , { ts : 1 } ) ;
89+ done ( ) ;
90+ } ) ;
91+ }
92+ } ) ;
93+ } , function ( ) {
94+ console . log ( "Fixing indexes on eventTimes collections" ) ;
95+ async . eachSeries ( apps , function ( app , done ) {
96+ countlyDb . collection ( 'eventTimes' + app . _id ) . ensureIndex ( { "uid" : 1 } , function ( ) {
8897 done ( ) ;
8998 } ) ;
90- }
91- } ) ;
92- } , function ( ) {
93- console . log ( "Fixing indexes on eventTimes collections" ) ;
94- async . eachSeries ( apps , function ( app , done ) {
95- countlyDb . collection ( 'eventTimes' + app . _id ) . ensureIndex ( { "uid" : 1 } , function ( ) {
96- done ( ) ;
99+ } , function ( ) {
100+ db . close ( ) ;
101+ countlyDb . close ( ) ;
102+ console . log ( "Drill index finished" ) ;
97103 } ) ;
98- } , function ( ) {
99- db . close ( ) ;
100- countlyDb . close ( ) ;
101- console . log ( "Drill index finished" ) ;
102104 } ) ;
103- } ) ;
105+ }
104106 } ) ;
105107 } ) ;
106108} ) ;
0 commit comments