File tree Expand file tree Collapse file tree 1 file changed +5
-19
lines changed Expand file tree Collapse file tree 1 file changed +5
-19
lines changed Original file line number Diff line number Diff line change @@ -78,29 +78,15 @@ pluginManager.dbConnection("countly").then(async(countlyDb) => {
7878
7979 var projections = { } ;
8080
81- var cursor = common . db . collection ( COLLECTION_NAME ) . find ( query ) . project ( projections ) ;
81+ var sort = { ls : - 1 } ;
82+
83+ var cursor = common . db . collection ( COLLECTION_NAME ) . find ( query ) . project ( projections ) . sort ( sort ) ;
8284
8385 while ( await cursor . hasNext ( ) ) {
8486 var doc = await cursor . next ( ) ;
85- if ( ! doc . username ) {
86- return ;
87- }
88-
89- var username = doc . username . trim ( ) ;
9087
91- if ( ! username . length ) {
92- return ;
93- }
94-
95- if ( ! mainUser ) {
96- mainUser = doc ;
97- }
98- else {
99- let currentMax = Math . max ( doc . ls , doc . lac ) ;
100- let mainMax = Math . max ( mainUser . ls , mainUser . lac ) ;
101- if ( currentMax > mainMax ) {
102- await mergeUsers ( doc , mainUser ) ;
103- mergedUsersUIDs . push ( mainUser . uid ) ;
88+ if ( doc . uid && doc . uid !== "" ) {
89+ if ( ! mainUser ) {
10490 mainUser = doc ;
10591 }
10692 else {
You can’t perform that action at this time.
0 commit comments