Skip to content

Commit

Permalink
fixed repo list portion of the query for deleting saved strings, see #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Dec 4, 2019
1 parent b0ef7a6 commit c425d48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/routeHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ module.exports.renderTranslationPage = async function( req, res ) {
} );

// create a parameterized query string for retrieving the user's previously saved strings
const savedStringsQuery = 'SELECT * from saved_translations where user_id = $1 AND locale = $2 AND (' + repositories + ')';
const savedStringsQuery = 'SELECT * FROM saved_translations WHERE user_id = $1 AND locale = $2 AND (' + repositories + ')';

// connect to the database and query for saved strings corresponding to this user and sim
let rows = null;
Expand Down
12 changes: 11 additions & 1 deletion js/stringSubmissionQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ module.exports.stringSubmissionQueue = async ( req, res ) => {

/**
* delete the strings that are stored in short-term storage
* {string} userID
* {string} locale
* {string[]} simOrLibNames
* @private
*/
async function deleteStringsFromDB( userID, locale, simOrLibNames ) {
Expand All @@ -178,7 +181,14 @@ async function deleteStringsFromDB( userID, locale, simOrLibNames ) {
'removing strings from short term storage for userID = ' + userID + ', sim/libs = ' + simOrLibNames + ', locale = ' + locale
);

const simOrLibNamesString = simOrLibNames.join( ' OR ' );
// create a string with all the repo names that can be used in the SQL query
let simOrLibNamesString = '';
simOrLibNames.forEach( ( simOrLibName, index ) => {
simOrLibNamesString += 'repository = ' + '\'' + simOrLibName + '\'';
if ( index < simOrLibNames.length - 1 ) {
simOrLibNamesString += ' OR ';
}
} );

const deleteQuery = 'DELETE FROM saved_translations WHERE user_id = $1 AND locale = $2 AND (' + simOrLibNamesString + ')';
const pool = new Pool();
Expand Down

0 comments on commit c425d48

Please sign in to comment.