Index: trunk/extensions/Storyboard/storyboard.sql |
— | — | @@ -19,4 +19,6 @@ |
20 | 20 | ) /*$wgDBTableOptions*/; |
21 | 21 | |
22 | 22 | CREATE INDEX story_published_modified ON /*$wgDBprefix*/storyboard (story_is_published, story_modified); |
23 | | -CREATE INDEX story_title ON /*$wgDBprefix*/storyboard (story_title); |
\ No newline at end of file |
| 23 | +CREATE INDEX story_modified_id ON /*$wgDBprefix*/storyboard (story_modified, story_id); |
| 24 | +CREATE INDEX story_title ON /*$wgDBprefix*/storyboard (story_title); |
| 25 | +ALTER TABLE /*$wgDBprefix*/storyboard ADD UNIQUE (story_title) |
\ No newline at end of file |
Index: trunk/extensions/Storyboard/api/ApiQueryStories.php |
— | — | @@ -57,9 +57,25 @@ |
58 | 58 | $this->addWhere( array( |
59 | 59 | 'story_is_published' => 1 |
60 | 60 | ) ); |
61 | | - $this->addOption( 'LIMIT', $params['limit'] ); |
62 | | - $this->addOption( 'ORDER BY', 'story_modified DESC' ); |
| 61 | + $this->addOption( 'LIMIT', $params['limit'] + 1 ); |
| 62 | + $this->addOption( 'ORDER BY', 'story_modified, story_id DESC' ); |
63 | 63 | |
| 64 | + if ( !is_null( $params['continue'] ) ) { |
| 65 | + $continueParams = explode( '|', $params['continue'] ); |
| 66 | + if ( count( $continueParams ) != 2 ) { |
| 67 | + $this->dieUsage( 'Invalid continue param. You should pass the ' . |
| 68 | + 'original value returned by the previous query', '_badcontinue' ); |
| 69 | + } |
| 70 | + |
| 71 | + $storyModified = $continueParams[0]; |
| 72 | + $storyId = intval( $continueParams[1] ); |
| 73 | + |
| 74 | + $this->addWhere( |
| 75 | + "story_modified < $storyModified OR " . |
| 76 | + "(story_modified = $storyId AND story_id <= $storyModified)" |
| 77 | + ); |
| 78 | + } |
| 79 | + |
64 | 80 | $stories = $this->select( __METHOD__ ); |
65 | 81 | $count = 0; |
66 | 82 | |
— | — | @@ -67,7 +83,7 @@ |
68 | 84 | if ( ++$count > $params['limit'] ) { |
69 | 85 | // We've reached the one extra which shows that |
70 | 86 | // there are additional pages to be had. Stop here... |
71 | | - $this->setContinueEnumParameter( 'continue', "" ); // TODO: add some weird stuff here |
| 87 | + $this->setContinueEnumParameter( 'continue', wfTimestamp(TS_MW, $row->story_modified) . '|' . $row->story_id ); // TODO: add some weird stuff here |
72 | 88 | break; |
73 | 89 | } |
74 | 90 | $res = array( |
— | — | @@ -126,8 +142,8 @@ |
127 | 143 | protected function getExamples() { |
128 | 144 | return array ( |
129 | 145 | 'api.php?action=query&list=stories', |
130 | | - 'api.php?action=query&list=stories&stcontinue=42', |
131 | | - 'api.php?action=query&list=stories&stcontinue=4&stlimit=2', |
| 146 | + 'api.php?action=query&list=stories&stlimit=42', |
| 147 | + 'api.php?action=query&list=stories&stcontinue=20100319202223|4&stlimit=2', |
132 | 148 | ); |
133 | 149 | } |
134 | 150 | |