Added actor date of birth and death precision.
This commit is contained in:
@@ -32,7 +32,9 @@ const mj = new MerkleJson();
|
||||
const keyMap = {
|
||||
avatar: 'avatar_media_id',
|
||||
dateOfBirth: 'date_of_birth',
|
||||
dateOfBirthPrecision: 'date_of_birth_precision',
|
||||
dateOfDeath: 'date_of_death',
|
||||
dateOfDeathPrecision: 'date_of_death_precision',
|
||||
originCountry: 'birth_country_alpha2',
|
||||
originState: 'birth_state',
|
||||
originCity: 'birth_city',
|
||||
@@ -62,6 +64,24 @@ const keyMap = {
|
||||
|
||||
const socialsOrder = ['onlyfans', 'fansly', 'twitter', 'instagram', 'loyalfans', 'manyvids', 'pornhub', 'linktree', null];
|
||||
|
||||
// with month (but not day) precision on either side, the age is still certain unless both dates fall in the same month,
|
||||
// since only then could the unknown day(s) put the birthday on either side of the reference date
|
||||
function isAgeApproximate(baseDate, basePrecision, referenceDate, referencePrecision = 'day') {
|
||||
if (!baseDate || !referenceDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (basePrecision === 'year' || referencePrecision === 'year') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (basePrecision === 'day' && referencePrecision === 'day') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return baseDate.getMonth() === referenceDate.getMonth();
|
||||
}
|
||||
|
||||
export function curateActor(actor, context = {}) {
|
||||
if (!actor) {
|
||||
return null;
|
||||
@@ -97,14 +117,20 @@ export function curateActor(actor, context = {}) {
|
||||
ageFromBirth: actor.date_of_birth && actor.date_of_birth.getFullYear() > 1
|
||||
? differenceInYears(Date.now(), actor.date_of_birth)
|
||||
: null,
|
||||
ageFromBirthIsApproximate: actor.date_of_birth_precision !== 'day'
|
||||
&& isAgeApproximate(actor.date_of_birth, actor.date_of_birth_precision, new Date()),
|
||||
ageAtDeath: actor.date_of_birth && actor.date_of_death && actor.date_of_birth.getFullYear() > 1
|
||||
? differenceInYears(actor.date_of_death, actor.date_of_birth)
|
||||
: null,
|
||||
ageAtDeathIsApproximate: (actor.date_of_birth_precision !== 'day' || actor.date_of_death_precision !== 'day')
|
||||
&& isAgeApproximate(actor.date_of_birth, actor.date_of_birth_precision, actor.date_of_death, actor.date_of_death_precision),
|
||||
ageThen: context.sceneDate && actor.date_of_birth && actor.date_of_birth.getFullYear() > 1
|
||||
? differenceInYears(context.sceneDate, actor.date_of_birth)
|
||||
: null,
|
||||
dateOfBirth: actor.date_of_birth,
|
||||
dateOfBirthPrecision: actor.date_of_birth_precision,
|
||||
dateOfDeath: actor.date_of_death,
|
||||
dateOfDeathPrecision: actor.date_of_death_precision,
|
||||
bust: actor.bust,
|
||||
cup: actor.cup,
|
||||
waist: actor.waist,
|
||||
@@ -1185,7 +1211,9 @@ async function applyActorRevision(revisionIds, reqUser) {
|
||||
'gender',
|
||||
'avatar',
|
||||
'dateOfBirth',
|
||||
'dateOfBirthPrecision',
|
||||
'dateOfDeath',
|
||||
'dateOfDeathPrecision',
|
||||
'originCountry',
|
||||
'originState',
|
||||
'originCity',
|
||||
|
||||
Reference in New Issue
Block a user