1. 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

Discussion in 'Installation, Upgrade, and Import Support' started by Crazy-Achmet, Mar 9, 2012.

  1. Crazy-Achmet

    Crazy-Achmet Active Member

    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
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Partial imports are not possible.
     
  3. Digital Doctor

    Digital Doctor Well-Known Member

    Expunge the unwanted threads before importing ?
     
  4. Crazy-Achmet

    Crazy-Achmet Active Member

    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.
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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;
    		}
    
     
    Reeve of Shinra and Crazy-Achmet like this.
  6. Crazy-Achmet

    Crazy-Achmet Active Member

    @ Jake: Thanks a lot, i will try it and give a feedback! :)
     
  7. Crazy-Achmet

    Crazy-Achmet Active Member

    Works flawless, but you also have to insert the datelinecheck for the polls in row 2490
     
    Reeve of Shinra likes this.

Share This Page