typo and cleanup

This commit is contained in:
2024-08-12 17:35:11 +03:00
parent 9c0a9db195
commit eebcc43eab
3 changed files with 2 additions and 50 deletions

View File

@@ -81,16 +81,6 @@ const selectProfilesForUser = async (roomId) => {
).rows[0];
const { lat, lng } = (await db.query("SELECT lat, lng FROM cities WHERE ID = $1", [mycity])).rows[0];
//Selecting profiles other than user's and fitting their needs
/*
2 * ASIN(SQRT(
POWER(SIN( (deg2rad(lat - $6::double precision)) / 2 ), 2)
+ COS(deg2rad(lat))
* COS(deg2rad($6::double precision))
* POWER(SIN(deg2rad(lng - $7::double precision)/2), 2)
))
* 6371 <= $5::double precision
*/
//
let user = (await db.query(`SELECT
room_id, name, age, sex, description, location, range FROM users
WHERE
@@ -199,24 +189,6 @@ const getUserLanguage = async (roomId) => {
return (await db.query("SELECT language FROM users WHERE room_id = $1", [roomId])).rows[0].language;
}
// const checkCountry = async (name) => {
// let res = (await db.query(`SELECT country AS name, levenshtein(country, $1) AS similarity
// FROM cities
// ORDER BY similarity ASC
// LIMIT 3`, [name])
// ).rows;
// if (res[0].similarity == 0) { // 'similarity' is actually inversed. The less 'similarity', the more it similar. 0 means the same
// return {
// exists: true
// };
// }
// return {
// exists: false,
// variants: res
// };
// }
const findCity = async (name) => {
return (await db.query(`SELECT ID, name, lat, lng, country, levenshtein(name, $1) AS similarity
FROM cities

View File

@@ -31,9 +31,7 @@ import {
uploadMediaAsMessage,
setUserLanguage,
getUserLanguage,
findCity,
getCityNameByID,
getCountryNameByID
findCity
} from './db.js';
import { processRequest, showRandomProfileToUser, showNewLikes } from "./interactions.js";
@@ -120,26 +118,8 @@ client.on("room.message", async (roomId, event) => {
lng5: cities[4].lng,
}))
} else {
// let cityName = await getCityNameByID(number);
// let countryName = await getCountryNameByID(number);
await processRequest(client, roomId, current_action, number, 'range');
}
// let checkResultCity = await checkCity(answer);
// if (!checkResultCity.exists) {
// await client.sendText(roomId, i18n.t(
// ["errors", "wrongcity"],
// {
// first: checkResultCity.variants[0].name,
// second: checkResultCity.variants[1].name,
// third: checkResultCity.variants[2].name,
// fourth: checkResultCity.variants[3].name,
// fifth: checkResultCity.variants[4].name,
// }
// ));
// return;
// }
// await processRequest(client, roomId, current_action, answer, 'range');
break;
case "range":
answer = parseInt(answer.split(" ")[0]);