Mepps has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397614 )

Change subject: End connections after query
......................................................................

End connections after query

Change-Id: Ic2ad2f4df9975baa5cd5b02634485568f844d149
---
M persistence.js
1 file changed, 15 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/dash 
refs/changes/14/397614/1

diff --git a/persistence.js b/persistence.js
index 188a9cf..6a52dca 100644
--- a/persistence.js
+++ b/persistence.js
@@ -32,7 +32,7 @@
                values.push( board.id );
                values.push( i );
        }
-       return connection.query( insertWidgets + placeholders, values );
+       return connection.query( insertWidgets + placeholders, values ).then( 
connection.end() );
 }
 
 module.exports = {
@@ -96,7 +96,9 @@
                                        return;
                                }
                                user.defaultBoard = dbResults[ 0 ][ 2 ][ 0 ].id;
-                               return connection.query( insertBigEnglish, [ 
userId ] );
+                               var result = connection.query( 
insertBigEnglish, [ userId ] )
+                                       .then( connection.end() );
+                               return result;
                        } );
        },
        /**
@@ -125,6 +127,7 @@
                }
                return connection.query( insert, insertParams ).then( function 
( dbResults ) {
                        instance.id = dbResults[ 0 ].insertId;
+                       connection.end();
                } );
        },
        /**
@@ -140,6 +143,7 @@
                return connection.query( select, [ instanceId, userId ] )
                        .then( function ( dbResults ) {
                                var result = dbResults[ 0 ][ 0 ];
+                connection.end();
                                if ( result.owner_id ) {
                                        return {
                                                id: instanceId,
@@ -187,6 +191,7 @@
                                                previewPath: rows[ i 
].preview_path
                                        };
                                }
+                               connection.end();
                                return result;
                        } );
        },
@@ -232,11 +237,12 @@
                                        return insertWidgetList( board, 
connection );
                                } );
                }
-               return connection.query( insert, insertParams )
+               return  connection.query( insert, insertParams )
                        .then( function ( dbResults ) {
                                board.id = dbResults[ 0 ].insertId;
                        } )
                        .then( function () {
+                               connection.end();
                                return insertWidgetList( board, connection );
                        } );
        },
@@ -251,7 +257,7 @@
                        connection = getConnection(),
                        select = 'SELECT owner_id, display_name, description, 
is_shared FROM dash_board WHERE id = ? AND ( is_shared OR owner_id = ? )';
 
-               return connection.query( select, [ boardId, userId ] )
+               var result = connection.query( select, [ boardId, userId ] )
                        .then( function ( dbResults ) {
                                var result = dbResults[ 0 ][ 0 ],
                                        widgetSelect = 'SELECT wi.id, 
wi.widget_id, w.code, wi.owner_id, wi.display_name, wi.description, 
wi.is_shared, wi.configuration FROM dash_widget_instance wi INNER JOIN 
dash_widget w on w.id = wi.widget_id INNER JOIN dash_widget_instance_board wib 
ON wi.id = wib.instance_id WHERE wib.board_id = ? ORDER BY wib.widget_position';
@@ -286,8 +292,10 @@
                                                configuration: JSON.parse( 
rows[ i ].configuration )
                                        };
                                }
+                               connection.end();
                                return board;
                        } );
+               return result;
        },
        /**
         * Retrieve all boards available to a user (theirs and shared boards)
@@ -315,6 +323,7 @@
                                                isShared: rows[ i ].is_shared 
=== 1
                                        };
                                }
+                               connection.end();
                                return result;
                        } );
        },
@@ -341,7 +350,9 @@
                                                previewPath: rows[ i 
].preview_path
                                        };
                                }
+                               connection.end();
                                return result;
                        } );
        }
+
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/397614
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2ad2f4df9975baa5cd5b02634485568f844d149
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/dash
Gerrit-Branch: master
Gerrit-Owner: Mepps <me...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to