Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release to prod 2024-09-02 #1342

Merged
merged 75 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a96c029
domain variable changed - added https
Sinamon-maker Jul 26, 2024
1fc26bd
поправил расстояние и убрал знаки препинания
Jul 12, 2024
37b89fc
выровнял текст заголовка посередине
Jul 12, 2024
3c9b3d2
added prototypes of buttons edit and delete
toprogramm Jul 17, 2024
b3be0be
added translation to dialog
toprogramm Jul 22, 2024
0f81db5
added dialog and stylized buttons
toprogramm Jul 22, 2024
821ce74
made naming for styles, the edit hides when event out of date
toprogramm Jul 26, 2024
8307b0d
fixed translations
toprogramm Jul 26, 2024
3c11678
tags padding fix
toprogramm Jul 26, 2024
36e7a5c
added component for test
toprogramm Jul 28, 2024
d1ab46c
fixed translation on modal windows with correct way
toprogramm Aug 2, 2024
181af90
changed routing after authorization
Sinamon-maker Jul 26, 2024
561d0eb
icons fixed to fill
toprogramm Jul 30, 2024
df4f339
changed fill on currentColor
toprogramm Jul 30, 2024
2ef8cfe
removed unuseble elements
toprogramm Jul 30, 2024
f51e315
changed on the old modified file
toprogramm Jul 30, 2024
37d4eba
fixed footer for desktop devices
toprogramm Jul 31, 2024
207be3e
Add model for cities with localization
Jul 1, 2024
f49467d
Add localization into parser, location and events controllers
Jul 8, 2024
ad09c1f
Add list of supported countries
Jul 1, 2024
2aa949c
Add supported countries enum
Jul 8, 2024
b751c10
Minor change to googledocs parser to comply with new location localiz…
Jul 8, 2024
b9d0384
Add localization to events routes controllers;
Jul 8, 2024
96046f9
Add localization to location endpoints
Jul 8, 2024
b710d6c
Add errors for nonexistent countries and cities
Jul 29, 2024
9d6b5b8
Fix copypaste typo and forgotten await bug
Jul 10, 2024
959583f
Add new format for usedCities
Aug 1, 2024
ceddd48
Fix schema.ts for used cities
Aug 2, 2024
ac95ccf
Fix forgotten return accum from reduce
Aug 5, 2024
97ea8e7
Remove console.log
Aug 6, 2024
a0a8df8
Set email to lower case before saving in database;
Aug 1, 2024
25290d5
Set email to lower case before saving in database;
Aug 1, 2024
39f9ac0
fixed back from create event after postauth
Sinamon-maker Aug 2, 2024
7aaea4a
removed unused locale variable
Sinamon-maker Aug 2, 2024
a5f458e
currency payload returned
Sinamon-maker Aug 3, 2024
8ce8a05
type Currency back
Sinamon-maker Aug 3, 2024
e9d3cb3
exclude modal temporarily from create page
Sinamon-maker Aug 6, 2024
d3624e6
redirect from create-event fixed, modal works
Sinamon-maker Aug 6, 2024
12f0c24
added headings on maain and meta
Sinamon-maker Aug 7, 2024
0dcffff
meta with | fixed
Sinamon-maker Aug 7, 2024
6b98876
when not found - headings not seen
Sinamon-maker Aug 7, 2024
fe70456
Remove location localization for online events
Aug 8, 2024
67a36ba
Add forgotten await
Aug 8, 2024
b8592fd
popover created
Sinamon-maker Aug 8, 2024
8be8a95
added for every currency number of decimals
Sinamon-maker Jul 12, 2024
fde7597
restriction to show peice added - 2 and 8 signs after devider
Sinamon-maker Jul 1, 2024
fac3eb6
fixed type currency in Peredelano event, restricted number input from…
Sinamon-maker Jul 4, 2024
dcc5ca4
added validation restriction fpr price in bitcoin and other currencies
Sinamon-maker Jul 4, 2024
7a3e6c4
type check error fixed
Sinamon-maker Jul 4, 2024
b867e5c
type check2 erroes fixed
Sinamon-maker Jul 4, 2024
695f9da
hack against scientific form for numbers less then 1 and fully reset …
Sinamon-maker Jul 5, 2024
627388f
Merge pull request #1305 from openworld-community/release/2024-08-18
il12 Aug 19, 2024
69ac97d
main page usedCiyies transformed
Sinamon-maker Aug 5, 2024
60fc1b3
library select returned
Sinamon-maker Aug 5, 2024
a3f3174
added new types
Sinamon-maker Aug 5, 2024
99e5dd6
Add alphabetical sorting for cities;
Aug 6, 2024
335bdf7
Add alphabetical sorting for cities;
Aug 6, 2024
34bc7af
Add alphabetical sorting for cities;
Aug 6, 2024
d31fde4
Merge pull request #1310 from openworld-community/release/2024-08-18
il12 Aug 22, 2024
0cb3092
check countries on front
Sinamon-maker Aug 5, 2024
922b698
create event finished
Sinamon-maker Aug 5, 2024
0b65945
Merge pull request #1311 from openworld-community/release/2024-08-18
il12 Aug 22, 2024
ab7d15b
Fix styles
Aug 22, 2024
1215931
Merge pull request #1312 from openworld-community/release/2024-08-18-…
il12 Aug 22, 2024
7f8ea28
changed name into path for hreflang
Sinamon-maker Aug 24, 2024
67aa97a
Merge pull request #1318 from openworld-community/fix-route-name
il12 Aug 25, 2024
06f5a8d
city on main on mobile in filter in local language
Sinamon-maker Aug 26, 2024
5446997
Merge pull request #1326 from openworld-community/fix-1323-mobile-lan…
il12 Aug 27, 2024
148a25e
fixed clear filters
Sinamon-maker Aug 27, 2024
b9b5ede
changed autocomplite for creating cities
Sinamon-maker Aug 27, 2024
3ce3a5a
select in creating cities
Sinamon-maker Aug 27, 2024
f922edc
Merge pull request #1332 from openworld-community/fix-create-own-city
Sinamon-maker Aug 27, 2024
ef27afc
Merge pull request #1330 from openworld-community/fix-usedCities-afte…
Sinamon-maker Aug 27, 2024
4990d91
headings on main on mobile added margin
Sinamon-maker Aug 28, 2024
c1fb7e3
Merge pull request #1333 from openworld-community/fix-headings-mobile…
Sinamon-maker Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/src/controllers/cities-for-parser.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ class Controller {
if (!city) return null;
return { type: 'city', name: city.name };
}

async findCountryByCityName(cityName: string) {
const city = await CitiesForParserModel.findOne({
alternateNames: cityName
});
if (!city) return null;
return city.countryCode;
}
}

export const citiesForParserController = new Controller();
195 changes: 153 additions & 42 deletions backend/src/controllers/countries-and-cities.controller.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,197 @@
import fs from 'fs';
import { EventModel } from '../models/event.model';
import { CitiesModel, ICity } from '../models/cities.model';
import { CommonErrorsEnum, SupportedCountries, SupportedLanguages } from '../../../common/const';
import { CountriesForParserModel } from '../models/countries-for-parser.model';
import { citiesForParserController } from './cities-for-parser.controller';
import { countriesForParserController } from './countries-for-parser.controller';

class CountriesAndCitiesController {
countries: string[];
async getLocalizedCities(lang: SupportedLanguages) {
const pipeline = [
{
$unset: ['countryCode', 'alternateNames', '_id']
}
];
const cities = await CitiesModel.aggregate(pipeline).exec();
return cities.map((city) => city[lang]);
}

citiesByCountry: { [key: string]: string[] } = {};
async getLocalizedCountries(lang: SupportedLanguages) {
const pipeline = [
{
$match: {
iso_3166_1_alpha_2_codes: {
$in: Object.values(SupportedCountries)
}
}
}
];
const countries = await CountriesForParserModel.aggregate(pipeline).exec();
return countries.map((country) => {
if (lang === SupportedLanguages.RUSSIAN) return country.russian_short!;
return country.english_short!;
});
}

constructor() {
const map = JSON.parse(fs.readFileSync('./assets/countries.json', 'utf8'));
async getLocalizedCityName(cityName: string, lang: SupportedLanguages) {
if (cityName === '') return '';
const city = await CitiesModel.findOne({
$or: [{ en: cityName }, { ru: cityName }, { alternateNames: cityName }]
});
if (!city) return cityName;
return city[lang];
}

this.countries = Object.keys(map);
this.citiesByCountry = map;
async getLocalizedCountryName(countryName: string, lang: SupportedLanguages) {
if (countryName === '') return '';
const country = await CountriesForParserModel.findOne({
$or: [
{ english_short: countryName },
{ french_short: countryName },
{ spanish_short: countryName },
{ russian_short: countryName }
]
});
if (!country) throw new Error(CommonErrorsEnum.COUNTRY_NOT_FOUND);
if (lang === SupportedLanguages.RUSSIAN) return country.russian_short!;
return country.english_short!;
}

async getCountryCodeByName(countryName: string) {
if (countryName === '') return '';
const country = await CountriesForParserModel.findOne({
$or: [
{ english_short: countryName },
{ french_short: countryName },
{ spanish_short: countryName },
{ russian_short: countryName }
]
});
if (!country) throw new Error(CommonErrorsEnum.COUNTRY_NOT_FOUND);
return country.iso_3166_1_alpha_2_codes!;
}

getCountryByCity(city: string) {
const { countries } = this;
if (countries.includes(city)) return city;
const possibleCountries = countries.filter((country) =>
this.citiesByCountry[country].includes(city)
async getCountryByCity(city: string) {
const countryCode = await citiesForParserController.findCountryByCityName(city);
if (!countryCode) throw new Error(CommonErrorsEnum.CITY_NOT_FOUND);
const countryName = await countriesForParserController.findEnglishCountryNameByCountryCode(
countryCode
);
return possibleCountries[0];
if (!countryName) throw new Error(CommonErrorsEnum.COUNTRY_NOT_FOUND);
return countryName;
}

getCitiesByCountry(country: string) {
const citiesByCountry = this.citiesByCountry[country];
return citiesByCountry;
async getCitiesByCountry(country: SupportedCountries, lang: SupportedLanguages) {
const pipeline = [
{
$match: {
countryCode: country
}
}
];

const cities = await CitiesModel.aggregate(pipeline).exec();
return cities.map((city) => city[lang]).sort((a: string, b: string) => (a < b ? -1 : 1));
}

async getUsedCountries() {
async getUsedCountries(lang: SupportedLanguages) {
const countries: string[] = await EventModel.distinct('location.country', {
'meta.moderation.status': { $nin: ['declined', 'in-progress'] },
$expr: {
$gte: [{ $add: ['$date', { $multiply: [1000, '$durationInSeconds'] }] }, Date.now()]
},
'location.country': { $nin: [''] }
});
return countries;
return Promise.all(
countries.map(async (country) => this.getLocalizedCountryName(country, lang))
);
}

async getUsedCitiesByCountry(country: string) {
const cities: string[] = await EventModel.distinct('location.city', {
const unprocessedCities: string[] = await EventModel.distinct('location.city', {
'location.country': country,
'meta.moderation.status': { $nin: ['declined', 'in-progress'] },
'location.city': { $nin: [''] },
$expr: {
$gte: [{ $add: ['$date', { $multiply: [1000, '$durationInSeconds'] }] }, Date.now()]
}
});
return cities;

const pipeline = [
{
$match: {
$or: [
{ en: { $in: unprocessedCities } },
{ ru: { $in: unprocessedCities } },
{ alternateNames: { $in: unprocessedCities } }
]
}
},
{
$unset: ['countryCode', 'alternateNames', '_id']
}
];

return CitiesModel.aggregate(pipeline).exec();
}

async getUsedCities() {
const cities: string[] = await EventModel.distinct('location.city', {
const unprocessedCities: string[] = await EventModel.distinct('location.city', {
'location.country': { $in: ['Serbia', 'Montenegro'] },
'meta.moderation.status': { $nin: ['declined', 'in-progress'] },
'location.city': { $nin: [''] },
$expr: {
$gte: [{ $add: ['$date', { $multiply: [1000, '$durationInSeconds'] }] }, Date.now()]
}
});
return cities;
}

getRandomPair({ country, city }: { country?: string; city?: string }) {
const getRandomCountry = () => {
const randomCountryIndex = Math.floor(Math.random() * this.countries.length);
const randomCountry = this.countries[randomCountryIndex];
return randomCountry;
};

const getRandomCity = (randomCountry: string) => {
const randomCityIndex = Math.floor(
Math.random() * (this.citiesByCountry[randomCountry]?.length || 0)
);
const randomCity = this.citiesByCountry[randomCountry]?.[randomCityIndex];
return randomCity;
};

const newCountry = country || getRandomCountry();
const newCity = city || getRandomCity(newCountry);

return { country: newCountry, city: newCity };
const pipeline = [
{
$match: {
$or: [
{ en: { $in: unprocessedCities } },
{ ru: { $in: unprocessedCities } },
{ alternateNames: { $in: unprocessedCities } }
]
}
},
{
$unset: ['alternateNames', '_id']
}
];

const citiesWithLocalization = await CitiesModel.aggregate(pipeline).exec();
const usedCities = citiesWithLocalization.reduce(
(accum, city: ICity) => {
const formattedCity = {
en: city.en,
ru: city.ru
};
if (city.countryCode === SupportedCountries.SERBIA) {
accum[0].cities.push(formattedCity);
accum[0].cities.sort((a: ICity, b: ICity) => (a.en < b.en ? -1 : 1));
}
if (city.countryCode === SupportedCountries.MONTENEGRO) {
accum[1].cities.push(formattedCity);
accum[1].cities.sort((a: ICity, b: ICity) => (a.en < b.en ? -1 : 1));
}
return accum;
},
[
{
en: 'Serbia',
ru: 'Сербия',
cities: []
},
{
en: 'Montengro',
ru: 'Черногория',
cities: []
}
]
);

return usedCities.filter((country: any) => country.cities.length !== 0);
}
}

Expand Down
8 changes: 8 additions & 0 deletions backend/src/controllers/countries-for-parser.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ class Controller {
if (!country) return null;
return { type: 'country', name: country.english_short };
}

async findEnglishCountryNameByCountryCode(countryCode: string) {
const country = await CountriesForParserModel.findOne({
iso_3166_1_alpha_2_codes: { $regex: countryCode, $options: 'i' }
});
if (!country) return null;
return country.english_short;
}
}

export const countriesForParserController = new Controller();
Loading
Loading