Jump to content

indexData improve index_data_updated


BomAle

Recommended Posts

ON \IPS\Content\Search\Index::indexData

/* Or if this *is* the first comment, add the title and replace the tags */
$title = $object->mapped('title');
$isForItem = FALSE;
if ( $object instanceof \IPS\Content\Comment )
{
	$itemClass = $class::$itemClass;
	if ( $itemClass::$firstCommentRequired and $object->isFirst() )
	{
		$title = $object->item()->mapped('title');
		$tags = ( $object->item() instanceof \IPS\Content\Tags and \IPS\Settings::i()->tags_enabled ) ? implode( ',', array_filter( $object->item()->tags() ) ) : NULL;
		$prefix = ( $object->item() instanceof \IPS\Content\Tags and \IPS\Settings::i()->tags_enabled ) ? $object->item()->prefix() : NULL;
		$isForItem = TRUE;
	}
}

/* Get the last updated date */
if ( $isForItem )
{
	$dateUpdated = $object->item()->mapped('last_comment');
}
else
{
	$dateUpdated = ( $object instanceof \IPS\Content\Item ) ? $object->mapped('last_comment') : $object->mapped('date');
}

I suggest to replace

( $object instanceof \IPS\Content\Item ) ? $object->mapped('last_comment') : $object->mapped('date');

//TO

( $object instanceof \IPS\Content\Item ) ?
	$object->mapped( isset($object::$databaseColumnMap['updated']) 
		? 'updated' 
		: 'last_comment' 
	) 
	: $object->mapped('date');

 

Link to comment
Share on other sites

I would actually suggest it be the other way - check for last_comment and if it doesn't exist, use updated. (I'm on my phone, I can't properly type code right now.)

@bfarber we can have searchable content items that don't have comments  (and therefore have no mapping for last_comment), but they still might have a mapping for updated. 

Link to comment
Share on other sites

15 hours ago, HeadStand said:

I would actually suggest it be the other way - check for last_comment and if it doesn't exist, use updated. (I'm on my phone, I can't properly type code right now.)

@bfarber we can have searchable content items that don't have comments  (and therefore have no mapping for last_comment), but they still might have a mapping for updated. 

Thanks - I've raised this internally for consideration.

Link to comment
Share on other sites

During discussions about this suggestion it was pointed out that anything that can be 'updated' would get bumped to the top of activity streams, which is inconsistent and not intended. Is there a valid use case for having content that is updated bump to the top of an activity stream?

Link to comment
Share on other sites

When user sort for Updated if some items are edited them must go on first page (for example wiki style content for pages app).

I am building a app that when items are updated the activity show the items on "recent updated" feed helping users find real updated items (page polls with optionally have comments).

I have not tested but I could extend get_last_comment and check for updated data if setted (not equal 0).

Link to comment
Share on other sites

11 hours ago, bfarber said:

During discussions about this suggestion it was pointed out that anything that can be 'updated' would get bumped to the top of activity streams, which is inconsistent and not intended. Is there a valid use case for having content that is updated bump to the top of an activity stream?

Fair enough. But I would still recommend checking if the last_comment mapping exists instead of assuming it does. ;)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...