Added affiliate parameters to scene URL.
This commit is contained in:
parent
c2edf72081
commit
9ce9cfbb0c
|
@ -210,6 +210,7 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
|
v-if="user"
|
||||||
class="menu-button menu-item logout"
|
class="menu-button menu-item logout"
|
||||||
@click="logout"
|
@click="logout"
|
||||||
><Icon icon="exit2" />Log out</li>
|
><Icon icon="exit2" />Log out</li>
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
:href="scene.url"
|
:href="scene.watchUrl"
|
||||||
:title="scene.date ? format(scene.date.toISOString(), 'y-MM-dd hh:mm') : `Release date unknown, added ${format(scene.createdAt, 'y-MM-dd')}`"
|
:title="scene.date ? format(scene.date.toISOString(), 'y-MM-dd hh:mm') : `Release date unknown, added ${format(scene.createdAt, 'y-MM-dd')}`"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="date-link nolink"
|
class="date-link nolink"
|
||||||
|
|
|
@ -2,10 +2,13 @@
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<a
|
<a
|
||||||
:href="entity.url"
|
:href="entityUrl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
class="link link-child"
|
class="link link-child"
|
||||||
|
:data-umami-event="entity.affiliate ? 'entity-click-aff' : 'entity-click'"
|
||||||
|
:data-umami-event-aff-id="entity.affiliate?.id"
|
||||||
|
:data-umami-event-entity="entity.slug"
|
||||||
>
|
>
|
||||||
<template v-if="entity.hasLogo">
|
<template v-if="entity.hasLogo">
|
||||||
<img
|
<img
|
||||||
|
@ -113,6 +116,23 @@ const children = ref(null);
|
||||||
const expanded = ref(false);
|
const expanded = ref(false);
|
||||||
|
|
||||||
const scrollable = computed(() => children.value?.scrollWidth > children.value?.clientWidth);
|
const scrollable = computed(() => children.value?.scrollWidth > children.value?.clientWidth);
|
||||||
|
|
||||||
|
const entityUrl = (() => {
|
||||||
|
if (!entity.url) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.affiliate?.parameters) {
|
||||||
|
return entity.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newParams = new URLSearchParams({
|
||||||
|
...Object.fromEntries(new URL(entity.url).searchParams),
|
||||||
|
...Object.fromEntries(new URLSearchParams(entity.affiliate.parameters)),
|
||||||
|
});
|
||||||
|
|
||||||
|
return `${entity.url}?${newParams}`;
|
||||||
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
:href="scene.url"
|
:href="scene.watchUrl"
|
||||||
:title="scene.date ? formatDate(scene.date.toISOString(), 'y-MM-dd hh:mm') : `Release date unknown, added ${formatDate(scene.createdAt, 'y-MM-dd')}`"
|
:title="scene.date ? formatDate(scene.date.toISOString(), 'y-MM-dd hh:mm') : `Release date unknown, added ${formatDate(scene.createdAt, 'y-MM-dd')}`"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="date nolink"
|
class="date nolink"
|
||||||
|
@ -142,10 +142,13 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
v-if="scene.url"
|
v-if="scene.watchUrl"
|
||||||
:href="scene.url"
|
:href="scene.watchUrl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="button button-primary watch nolink"
|
class="button button-primary watch nolink"
|
||||||
|
:data-umami-event="scene.affiliate ? 'watch-click-aff' : 'watch-click'"
|
||||||
|
:data-umami-event-aff-id="scene.affiliate?.id"
|
||||||
|
:data-umami-event-scene-id="scene.id"
|
||||||
>Watch full video</Link>
|
>Watch full video</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -19,6 +19,11 @@ export function curateEntity(entity, context) {
|
||||||
hasLogo: entity.has_logo,
|
hasLogo: entity.has_logo,
|
||||||
parent: curateEntity(entity.parent, context),
|
parent: curateEntity(entity.parent, context),
|
||||||
children: context?.children?.filter((child) => child.parent_id === entity.id).map((child) => curateEntity({ ...child, parent: entity }, { parent: entity })) || [],
|
children: context?.children?.filter((child) => child.parent_id === entity.id).map((child) => curateEntity({ ...child, parent: entity }, { parent: entity })) || [],
|
||||||
|
affiliate: entity.affiliate ? {
|
||||||
|
id: entity.affiliate.id,
|
||||||
|
url: entity.affiliate.url,
|
||||||
|
parameters: entity.affiliate.parameters,
|
||||||
|
} : null,
|
||||||
...context?.append?.[entity.id],
|
...context?.append?.[entity.id],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -66,15 +71,20 @@ export async function fetchEntities(options) {
|
||||||
export async function fetchEntitiesById(entityIds, options = {}) {
|
export async function fetchEntitiesById(entityIds, options = {}) {
|
||||||
const [entities, children] = await Promise.all([
|
const [entities, children] = await Promise.all([
|
||||||
knex('entities')
|
knex('entities')
|
||||||
.select('entities.*', knex.raw('row_to_json(parents) as parent'))
|
.select(
|
||||||
|
'entities.*',
|
||||||
|
knex.raw('row_to_json(parents) as parent'),
|
||||||
|
knex.raw('row_to_json(affiliates) as affiliate'),
|
||||||
|
)
|
||||||
.whereIn('entities.id', entityIds)
|
.whereIn('entities.id', entityIds)
|
||||||
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
|
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
|
||||||
|
.leftJoin('affiliates', knex.raw('affiliates.entity_id in (entities.id, parents.id)'))
|
||||||
.modify((builder) => {
|
.modify((builder) => {
|
||||||
if (options.order) {
|
if (options.order) {
|
||||||
builder.orderBy(...options.order);
|
builder.orderBy(...options.order);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.groupBy('entities.id', 'parents.id'),
|
.groupBy('entities.id', 'parents.id', 'affiliates.id'),
|
||||||
options.includeChildren ? knex('entities')
|
options.includeChildren ? knex('entities')
|
||||||
.whereIn('entities.parent_id', entityIds)
|
.whereIn('entities.parent_id', entityIds)
|
||||||
.orderBy('slug') : [],
|
.orderBy('slug') : [],
|
||||||
|
|
|
@ -12,12 +12,47 @@ import { curateMedia } from './media.js';
|
||||||
import escape from '../utils/escape-manticore.js';
|
import escape from '../utils/escape-manticore.js';
|
||||||
import promiseProps from '../utils/promise-props.js';
|
import promiseProps from '../utils/promise-props.js';
|
||||||
|
|
||||||
|
function getWatchUrl(scene) {
|
||||||
|
if (scene.url) {
|
||||||
|
return scene.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scene.channel && (scene.channel.isIndependent || scene.channel.type === 'network')) {
|
||||||
|
return scene.channel.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scene.network) {
|
||||||
|
return scene.network.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAffiliateUrl(scene) {
|
||||||
|
const watchUrl = getWatchUrl(scene);
|
||||||
|
|
||||||
|
if (!watchUrl) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!scene.affiliate?.parameters) {
|
||||||
|
return scene.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newParams = new URLSearchParams({
|
||||||
|
...Object.fromEntries(new URL(watchUrl).searchParams),
|
||||||
|
...Object.fromEntries(new URLSearchParams(scene.affiliate.parameters)),
|
||||||
|
});
|
||||||
|
|
||||||
|
return `${watchUrl}?${newParams.toString()}`;
|
||||||
|
}
|
||||||
|
|
||||||
function curateScene(rawScene, assets) {
|
function curateScene(rawScene, assets) {
|
||||||
if (!rawScene) {
|
if (!rawScene) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
const curatedScene = {
|
||||||
id: rawScene.id,
|
id: rawScene.id,
|
||||||
title: rawScene.title,
|
title: rawScene.title,
|
||||||
slug: rawScene.slug,
|
slug: rawScene.slug,
|
||||||
|
@ -43,6 +78,11 @@ function curateScene(rawScene, assets) {
|
||||||
type: assets.channel.network_type,
|
type: assets.channel.network_type,
|
||||||
hasLogo: assets.channel.has_logo,
|
hasLogo: assets.channel.has_logo,
|
||||||
} : null,
|
} : null,
|
||||||
|
affiliate: assets.channel.affiliate ? {
|
||||||
|
id: assets.channel.affiliate.id,
|
||||||
|
url: assets.channel.affiliate.url,
|
||||||
|
parameters: assets.channel.affiliate.parameters,
|
||||||
|
} : null,
|
||||||
actors: sortActorsByGender(assets.actors.map((actor) => curateActor(actor, {
|
actors: sortActorsByGender(assets.actors.map((actor) => curateActor(actor, {
|
||||||
sceneDate: rawScene.effective_date,
|
sceneDate: rawScene.effective_date,
|
||||||
stashes: assets.actorStashes.filter((actorStash) => actorStash.actor_id === actor.id),
|
stashes: assets.actorStashes.filter((actorStash) => actorStash.actor_id === actor.id),
|
||||||
|
@ -80,6 +120,10 @@ function curateScene(rawScene, assets) {
|
||||||
updatedBatchId: rawScene.updated_batch_id,
|
updatedBatchId: rawScene.updated_batch_id,
|
||||||
isNew: assets.lastBatchId === rawScene.created_batch_id,
|
isNew: assets.lastBatchId === rawScene.created_batch_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
curatedScene.watchUrl = getAffiliateUrl(curatedScene);
|
||||||
|
|
||||||
|
return curatedScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||||
|
@ -101,11 +145,19 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||||
} = await promiseProps({
|
} = await promiseProps({
|
||||||
scenes: knex('releases').whereIn('releases.id', sceneIds),
|
scenes: knex('releases').whereIn('releases.id', sceneIds),
|
||||||
channels: knex('releases')
|
channels: knex('releases')
|
||||||
.select('channels.*', 'networks.id as network_id', 'networks.slug as network_slug', 'networks.name as network_name', 'networks.type as network_type')
|
.select(
|
||||||
|
'channels.*',
|
||||||
|
'networks.id as network_id',
|
||||||
|
'networks.slug as network_slug',
|
||||||
|
'networks.name as network_name',
|
||||||
|
'networks.type as network_type',
|
||||||
|
knex.raw('row_to_json(affiliates) as affiliate'),
|
||||||
|
)
|
||||||
.whereIn('releases.id', sceneIds)
|
.whereIn('releases.id', sceneIds)
|
||||||
.leftJoin('entities as channels', 'channels.id', 'releases.entity_id')
|
.leftJoin('entities as channels', 'channels.id', 'releases.entity_id')
|
||||||
.leftJoin('entities as networks', 'networks.id', 'channels.parent_id')
|
.leftJoin('entities as networks', 'networks.id', 'channels.parent_id')
|
||||||
.groupBy('channels.id', 'networks.id'),
|
.leftJoin('affiliates', knex.raw('affiliates.entity_id in (channels.id, networks.id)'))
|
||||||
|
.groupBy('channels.id', 'networks.id', 'affiliates.id'),
|
||||||
actors: knex('releases_actors')
|
actors: knex('releases_actors')
|
||||||
.select(
|
.select(
|
||||||
'actors.*',
|
'actors.*',
|
||||||
|
|
|
@ -24,8 +24,6 @@ export async function curateScenesQuery(query) {
|
||||||
notEntityIds: await getIdsBySlug(splitEntities.filter((entity) => entity.charAt(0) === '!').map((entity) => entity.slice(1)), 'entities'),
|
notEntityIds: await getIdsBySlug(splitEntities.filter((entity) => entity.charAt(0) === '!').map((entity) => entity.slice(1)), 'entities'),
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('QUERY', query);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
scope: query.scope || 'latest',
|
scope: query.scope || 'latest',
|
||||||
query: query.q,
|
query: query.q,
|
||||||
|
|
2
static
2
static
|
@ -1 +1 @@
|
||||||
Subproject commit 76242feb7b3e75bcc581d9b19ee509c6e01a87aa
|
Subproject commit 39f91b96b2bfa176a02d10c9051dd1d2f9c62b64
|
Loading…
Reference in New Issue