Returns the sum of outgoing or incoming links for the provided page IDs. Args: page_ids: A list of page IDs whose outgoing or incoming links to count. Returns: int: The count of outgoing or incoming links.
(self, page_ids, incoming_or_outgoing_links_count)
| 154 | return self.fetch_links_count_helper(page_ids, 'incoming_links_count') |
| 155 | |
| 156 | def fetch_links_count_helper(self, page_ids, incoming_or_outgoing_links_count): |
| 157 | """Returns the sum of outgoing or incoming links for the provided page IDs. |
| 158 | |
| 159 | Args: |
| 160 | page_ids: A list of page IDs whose outgoing or incoming links to count. |
| 161 | |
| 162 | Returns: |
| 163 | int: The count of outgoing or incoming links. |
| 164 | """ |
| 165 | page_ids = str(tuple(page_ids)).replace(',)', ')') |
| 166 | |
| 167 | # There is no need to escape the query parameters here since they are never user-defined. |
| 168 | query = 'SELECT SUM({0}) FROM links WHERE id IN {1};'.format( |
| 169 | incoming_or_outgoing_links_count, page_ids) |
| 170 | self.sdow_cursor.execute(query) |
| 171 | |
| 172 | return self.sdow_cursor.fetchone()[0] |
| 173 | |
| 174 | def fetch_outgoing_links(self, page_ids): |
| 175 | """Returns a list of tuples of page IDs representing outgoing links from the list of provided |
no outgoing calls
no test coverage detected