3 * Store last-touched ID for various timelines
9 * @author Evan Prodromou <evan@status.net>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2010, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
37 * Store various timeline data
39 * We don't want to keep re-fetching the same statuses and direct messages from Twitter.
40 * So, we store the last ID we see from a timeline, and store it. Next time
41 * around, we use that ID in the since_id parameter.
45 * @author Evan Prodromou <evan@status.net>
46 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
47 * @link http://status.net/
51 class Twitter_synch_status extends Managed_DataObject
53 public $__table = 'twitter_synch_status'; // table name
54 public $foreign_id; // bigint primary_key not_null
55 public $timeline; // varchar(191) primary_key not_null not 255 because utf8mb4 takes more space
56 public $last_id; // bigint not_null
57 public $created; // datetime() not_null
58 public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
60 public static function schemaDef()
64 'foreign_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'Foreign message ID'),
65 'timeline' => array('type' => 'varchar', 'length' => 191, 'description' => 'timeline name'),
66 'last_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'last id fetched'),
67 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
68 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
70 'primary key' => array('foreign_id', 'timeline'),
74 static function getLastId($foreign_id, $timeline)
76 $tss = self::pkeyGet(array('foreign_id' => $foreign_id,
77 'timeline' => $timeline));
86 static function setLastId($foreign_id, $timeline, $last_id)
88 $tss = self::pkeyGet(array('foreign_id' => $foreign_id,
89 'timeline' => $timeline));
92 $tss = new Twitter_synch_status();
94 $tss->foreign_id = $foreign_id;
95 $tss->timeline = $timeline;
96 $tss->last_id = $last_id;
97 $tss->created = common_sql_now();
98 $tss->modified = $tss->created;
106 $tss->last_id = $last_id;
107 $tss->modified = common_sql_now();