Index: trunk/extensions/CodeReview/backend/CodeRepository.php |
— | — | @@ -126,7 +126,32 @@ |
127 | 127 | $wgMemc->set( $key, $authors, 3600 * 24 ); |
128 | 128 | return $authors; |
129 | 129 | } |
| 130 | + |
| 131 | + public function getAuthorCount() { |
| 132 | + global $wgMemc; |
| 133 | + $key = wfMemcKey( 'codereview', 'authorcount', $this->getId() ); |
| 134 | + $authorsCount = $wgMemc->get( $key ); |
| 135 | + if ( is_int( $authorsCount ) ) { |
| 136 | + return $authorsCount; |
| 137 | + } |
| 138 | + $dbr = wfGetDB( DB_SLAVE ); |
| 139 | + $row = $dbr->select( |
| 140 | + 'code_authors', |
| 141 | + array( 'COUNT(cr_author) AS author_count' ), |
| 142 | + array( 'cr_repo_id' => $this->getId() ), |
| 143 | + __METHOD__ |
| 144 | + ); |
130 | 145 | |
| 146 | + if ( !$row ) { |
| 147 | + throw new MWException( 'Failed to load expected author count' ); |
| 148 | + } |
| 149 | + |
| 150 | + $authorsCount = intval( $row->author_count ); |
| 151 | + |
| 152 | + $wgMemc->set( $key, $authorsCount, 3600 * 24 ); |
| 153 | + return $authorsCount; |
| 154 | + } |
| 155 | + |
131 | 156 | public function getTagList() { |
132 | 157 | global $wgMemc; |
133 | 158 | $key = wfMemcKey( 'codereview', 'tags', $this->getId() ); |
— | — | @@ -167,8 +192,9 @@ |
168 | 193 | ), |
169 | 194 | __METHOD__ |
170 | 195 | ); |
171 | | - if ( !$row ) |
| 196 | + if ( !$row ) { |
172 | 197 | throw new MWException( 'Failed to load expected revision data' ); |
| 198 | + } |
173 | 199 | return CodeRevision::newFromRow( $this, $row ); |
174 | 200 | } |
175 | 201 | |