openvibers/openvibe.tours Commits
Search documents' bodies hold only what their summary does not (#42)
Changes
@@@ -34,7 +34,8 @@ function describePlace(row) {listed: true,title,summary: [about, clip(row.description, 220), ...facts].filter(Boolean).join(' '),-- body: [title, about, row.description, row.address, ...facts].filter(Boolean).join('\n'),++ // The body holds only what the summary does not (Search's snippet reads both, and repeated the first line).++ body: [row.description && row.description.length > 220 ? row.description : '', row.address].filter(Boolean).join('\n'),facets: { city: row.city_slug, country: row.country, kind: row.kind },authorship: { mode: 'imported' },publishedAt: iso(row.created_at),@@@ -51,7 +52,7 @@ function describeCity(row) {noindex: !places && !routes,title: `${row.name}, ${row.country}`,summary: [clip(row.summary, 260), what].filter(Boolean).join(' '),-- body: [`${row.name}, ${row.region ? `${row.region}, ` : ''}${row.country}`, row.summary, what, 'Things to do, places to see, walks, stays and flights.'].filter(Boolean).join('\n'),++ body: [row.region ? `${row.name}, ${row.region}, ${row.country}` : '', row.summary && row.summary.length > 260 ? row.summary : '', 'Things to do, places to see, walks, stays and flights.'].filter(Boolean).join('\n'),facets: { city: row.id, country: row.country, places, routes },authorship: { mode: 'imported' },publishedAt: iso(row.created_at),@@@ -68,7 +69,7 @@ function describeRoute(row) {noindex: !Number(row.stop_count),title: row.title,summary: [about, clip(row.summary, 220)].filter(Boolean).join(' '),-- body: [row.title, about, row.summary].filter(Boolean).join('\n'),++ body: row.summary && row.summary.length > 220 ? row.summary : '',facets: { city: row.city_slug, country: row.country, stops: Number(row.stop_count) || 0, distance_m: Number(row.distance_m) || 0, duration_min: Number(row.duration_min) || 0 },authorship: { mode: 'imported' },publishedAt: iso(row.created_at),@@@ -49,7 +49,7 @@ const node = (tags) => ({ type: 'node', id: 9001, lat: 29.56, lon: 106.58, tags:const env = (await t.ctx.s.db.many("SELECT envelope FROM event_outbox WHERE envelope->'payload'->>'id' = $1", [id])).pop();assert.ok(env, 'an envelope for the place');assert.strictEqual(env.envelope.payload.title, 'Hongya Cave (洪崖洞)');-- assert.match(env.envelope.payload.body, /Hongya Cave \(洪崖洞\)/);++ assert.ok(!String(env.envelope.payload.body || '').includes('Attraction in'), 'the body does not repeat the summary (the snippet reads both)');});await check('the places job names a version, so a run under older rules is not fresh', async () => {
@@ -34,7 +34,8 @@ function describePlace(row) {
@@ -34,7 +34,8 @@ function describePlace(row) {
listed: true,
listed: true,
title,
title,
summary: [about, clip(row.description, 220), ...facts].filter(Boolean).join(' '),
summary: [about, clip(row.description, 220), ...facts].filter(Boolean).join(' '),
- body: [title, about, row.description, row.address, ...facts].filter(Boolean).join('\n'),
+ // The body holds only what the summary does not (Search's snippet reads both, and repeated the first line).
+ body: [row.description && row.description.length > 220 ? row.description : '', row.address].filter(Boolean).join('\n'),
facets: { city: row.city_slug, country: row.country, kind: row.kind },
facets: { city: row.city_slug, country: row.country, kind: row.kind },
authorship: { mode: 'imported' },
authorship: { mode: 'imported' },
publishedAt: iso(row.created_at),
publishedAt: iso(row.created_at),
@@ -51,7 +52,7 @@ function describeCity(row) {
@@ -51,7 +52,7 @@ function describeCity(row) {
noindex: !places && !routes,
noindex: !places && !routes,
title: `${row.name}, ${row.country}`,
title: `${row.name}, ${row.country}`,
summary: [clip(row.summary, 260), what].filter(Boolean).join(' '),
summary: [clip(row.summary, 260), what].filter(Boolean).join(' '),
- body: [`${row.name}, ${row.region ? `${row.region}, ` : ''}${row.country}`, row.summary, what, 'Things to do, places to see, walks, stays and flights.'].filter(Boolean).join('\n'),
+ body: [row.region ? `${row.name}, ${row.region}, ${row.country}` : '', row.summary && row.summary.length > 260 ? row.summary : '', 'Things to do, places to see, walks, stays and flights.'].filter(Boolean).join('\n'),
facets: { city: row.id, country: row.country, places, routes },
facets: { city: row.id, country: row.country, places, routes },
authorship: { mode: 'imported' },
authorship: { mode: 'imported' },
publishedAt: iso(row.created_at),
publishedAt: iso(row.created_at),
@@ -68,7 +69,7 @@ function describeRoute(row) {
@@ -68,7 +69,7 @@ function describeRoute(row) {
noindex: !Number(row.stop_count),
noindex: !Number(row.stop_count),
title: row.title,
title: row.title,
summary: [about, clip(row.summary, 220)].filter(Boolean).join(' '),
summary: [about, clip(row.summary, 220)].filter(Boolean).join(' '),
- body: [row.title, about, row.summary].filter(Boolean).join('\n'),
+ body: row.summary && row.summary.length > 220 ? row.summary : '',
facets: { city: row.city_slug, country: row.country, stops: Number(row.stop_count) || 0, distance_m: Number(row.distance_m) || 0, duration_min: Number(row.duration_min) || 0 },
facets: { city: row.city_slug, country: row.country, stops: Number(row.stop_count) || 0, distance_m: Number(row.distance_m) || 0, duration_min: Number(row.duration_min) || 0 },
authorship: { mode: 'imported' },
authorship: { mode: 'imported' },
publishedAt: iso(row.created_at),
publishedAt: iso(row.created_at),
@@ -49,7 +49,7 @@ const node = (tags) => ({ type: 'node', id: 9001, lat: 29.56, lon: 106.58, tags:
@@ -49,7 +49,7 @@ const node = (tags) => ({ type: 'node', id: 9001, lat: 29.56, lon: 106.58, tags:
const env = (await t.ctx.s.db.many("SELECT envelope FROM event_outbox WHERE envelope->'payload'->>'id' = $1", [id])).pop();
const env = (await t.ctx.s.db.many("SELECT envelope FROM event_outbox WHERE envelope->'payload'->>'id' = $1", [id])).pop();
assert.ok(env, 'an envelope for the place');
assert.ok(env, 'an envelope for the place');
assert.strictEqual(env.envelope.payload.title, 'Hongya Cave (洪崖洞)');
assert.strictEqual(env.envelope.payload.title, 'Hongya Cave (洪崖洞)');
- assert.match(env.envelope.payload.body, /Hongya Cave \(洪崖洞\)/);
+ assert.ok(!String(env.envelope.payload.body || '').includes('Attraction in'), 'the body does not repeat the summary (the snippet reads both)');
});
});
await check('the places job names a version, so a run under older rules is not fresh', async () => {
await check('the places job names a version, so a run under older rules is not fresh', async () => {