Skip to content

Commit

Permalink
Started working on matching algorythm
Browse files Browse the repository at this point in the history
  • Loading branch information
RedcodesDev committed Jun 8, 2024
1 parent b1794b6 commit a3d5568
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions static/utils/matchingUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
function getPossibleMatches(rawSex, rawSexuality) {

//Calculate all sexualties with all genders
var allSexes = [];
var allSexualities = [];
const sexualities = JSON.parse(JSON.stringify(Sexuality));
for (var key in sexualities) {
allSexualities.push(sexualities[key]);
}
const sexes = JSON.parse(JSON.stringify(Sex));
for (var key in sexes) {
allSexes.push({
sex: sexes[key],
sexualities: allSexualities
});
}

const sex = getSex(rawSex);
const sexuality = getSexuality(rawSexuality);
switch (sex) {
case Sex.MALE:
switch (sexuality) {
case Sexuality.ASEXUAL:
return allSexes;
case Sexuality.ANDROSEXUAL:
return [{
sex: Sex.MALE,
sexualities: [Sexuality.ASEXUAL, Sexuality.BISEXUAL, Sexuality.HOMOSEXUAL, Sexuality.DEMISEXUAL, Sexuality.PANSEXUAL, Sexuality.POLYSEXUAL, Sexuality.NOWOMASEXUAL, Sexuality.UNLABLED]
}];
case Sexuality.BISEXUAL:
return [{
sex: Sex.MALE,
sexualities: [Sexuality.ASEXUAL, Sexuality.BISEXUAL, Sexuality.HOMOSEXUAL, Sexuality.ANDROSEXUAL, Sexuality.DEMISEXUAL, Sexuality.PANSEXUAL, Sexuality.POLYSEXUAL, Sexuality.NOWOMASEXUAL, Sexuality.UNLABLED]
}, {
sex: Sex.FEMALE,
sexualities: [Sexuality.ASEXUAL, Sexuality.BISEXUAL, Sexuality.HETEROSEXUAL, Sexuality.PANSEXUAL, Sexuality.ANDROSEXUAL, Sexuality.POLYSEXUAL, Sexuality.NOWOMASEXUAL, Sexuality.UNLABLED]
}];
case Sexuality.DEMISEXUAL:
return allSexes;
case Sexuality.GYNOSEXUAL:
return [Sex.FEMALE];
case Sexuality.HETEROSEXUAL:
return [Sex.FEMALE];
case Sexuality.HOMOSEXUAL:
return [Sex.MALE];
case Sexuality.PANSEXUAL:
return allSexes;
case Sexuality.POLYSEXUAL:
return allSexes;
case Sexuality.NOMASEXUAL:
return Object.keys(Sex).splice(allSexes.indexOf(Sex.MALE), 1);
case Sexuality.NOWOMASEXUAL:
return Object.keys(Sex).splice(allSexes.indexOf(Sex.FEMALE), 1);
case Sexuality.UNLABLED:
return allSexes;
case Sexuality.SKOLIOSEXUAL:
return [Sex.NONBINARY];

}
break;

case Sex.FEMALE:

break;


}
}


const Sexuality = {
ASEXUAL: 'Asexuell',
ANDROSEXUAL: 'Androsexuell',
BISEXUAL: 'Bisexuell',
DEMISEXUAL: 'Demisexuell',
GYNOSEXUAL: 'Gynosexuell',
HETEROSEXUAL: 'Heterosexuell',
HOMOSEXUAL: 'Homosexuell',
PANSEXUAL: 'Pansexuell',
POLYSEXUAL: 'Polysexuell',
NOMASEXUAL: 'Nomasexuell',
NOWOMASEXUAL: 'Nowomasexuell',
UNLABLED: 'Unlabled',
SKOLIOSEXUAL: 'Skoliosexuell',
}

const Sex = {
MALE: 'Männlich',
FEMALE: 'Weiblich',
INTERSEX: 'Intergeschlechtlich',
GENDERFLUID: 'Genderfluid',
TRANSGENDER: 'Transgender',
BIGENDER: 'Bigender',
NONBINARY: 'Non-Binary',
}

function getSexuality(str) {
const sexualities = JSON.parse(JSON.stringify(Sexuality));
for (var key in sexualities) {
if (str.includes(sexualities[key])) {
return sexualities[key];
}
}

return null;
}

function getSex(str) {
const sexes = JSON.parse(JSON.stringify(Sex));
for (var key in sexes) {
if (str.includes(sexes[key])) {
return sexes[key];
}
}

return null;

}

0 comments on commit a3d5568

Please sign in to comment.