• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 [vb3.8] Do not import Threads older then XXX days

#1
Hey,

just a small question. Is it possible to import only threads that were created in last XXX days?

I don't want to import > 6 Million posts everytime i have to test something out. Maybe i can set an option (even a filechange would be ok for me) to give this setting to the importer?

Thanks in advance for your help

Florian
 
#4
I'm importing from a daily copy from a live site and i don't want to "touch" that backup and delete all the older threads every time.

I thought there was an easy way to do it, damn!

But thanks anyway.
 

Jake Bunce

XenForo moderator
Staff member
#5
Not tested but...

library/XenForo/Importer/vBulletin.php

Add the red code:

Code:
	public function stepThreads($start, array $options)
	{
		$options = array_merge(array(
			'limit' => 100,
			'postDateStart' => 0,
			'postLimit' => 800,
			'max' => false
		), $options);

		$sDb = $this->_sourceDb;
		$prefix = $this->_prefix;

		/* @var $model XenForo_Model_Import */
		$model = $this->_importModel;

		if ($options['max'] === false)
		{
			$options['max'] = $sDb->fetchOne('
				SELECT MAX(threadid)
				FROM ' . $prefix . 'thread
			');
		}

		// pull threads from things we actually imported as forums
		$threads = $sDb->fetchAll($sDb->limit(
			'
				SELECT thread.*,
					IF(user.username IS NULL, thread.postusername, user.username) AS postusername
				FROM ' . $prefix . 'thread AS thread FORCE INDEX (PRIMARY)
				LEFT JOIN ' . $prefix . 'user AS user ON (thread.postuserid = user.userid)
				INNER JOIN ' . $prefix . 'forum AS forum ON
					(thread.forumid = forum.forumid AND forum.link = \'\' AND forum.options & 4)
				WHERE thread.threadid >= ' . $sDb->quote($start) . '
					AND thread.open <> 10
					AND thread.dateline > UNIX_TIMESTAMP('2012-01-15 00:00:00')
				ORDER BY thread.threadid
			', $options['limit']
		));
		if (!$threads)
		{
			return true;
		}