Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/db.py
Show First 20 Lines • Show All 387 Lines • ▼ Show 20 Lines | def origin_intrinsic_metadata_search_fulltext(self, terms, *, limit, cur): | ||||
"ORDER BY ts_rank(oim.metadata_tsvector, tsq, 1) DESC " | "ORDER BY ts_rank(oim.metadata_tsvector, tsq, 1) DESC " | ||||
"LIMIT %s;" | "LIMIT %s;" | ||||
).format(keys=', '.join(keys), | ).format(keys=', '.join(keys), | ||||
tsquery_template=tsquery_template) | tsquery_template=tsquery_template) | ||||
cur.execute(query, tsquery_args + [limit]) | cur.execute(query, tsquery_args + [limit]) | ||||
yield from cur | yield from cur | ||||
def origin_intrinsic_metadata_search_by_producer( | def origin_intrinsic_metadata_search_by_producer( | ||||
self, start, end, limit, ids_only, mappings, tool_ids, cur): | self, last, limit, ids_only, mappings, tool_ids, cur): | ||||
if ids_only: | if ids_only: | ||||
keys = 'oim.id' | keys = 'oim.id' | ||||
else: | else: | ||||
keys = ', '.join((self._convert_key(col, 'oim') for col in | keys = ', '.join((self._convert_key(col, 'oim') for col in | ||||
self.origin_intrinsic_metadata_cols)) | self.origin_intrinsic_metadata_cols)) | ||||
query_parts = [ | query_parts = [ | ||||
"SELECT %s" % keys, | "SELECT %s" % keys, | ||||
"FROM origin_intrinsic_metadata AS oim", | "FROM origin_intrinsic_metadata AS oim", | ||||
"INNER JOIN indexer_configuration AS i", | "INNER JOIN indexer_configuration AS i", | ||||
"ON oim.indexer_configuration_id=i.id", | "ON oim.indexer_configuration_id=i.id", | ||||
] | ] | ||||
args = [] | args = [] | ||||
where = [] | where = [] | ||||
if start: | if last: | ||||
where.append('oim.id >= %s') | where.append('oim.id > %s') | ||||
args.append(start) | args.append(last) | ||||
if end: | |||||
where.append('oim.id <= %s') | |||||
args.append(end) | |||||
if mappings is not None: | if mappings is not None: | ||||
where.append('oim.mappings && %s') | where.append('oim.mappings && %s') | ||||
args.append(mappings) | args.append(mappings) | ||||
if tool_ids is not None: | if tool_ids is not None: | ||||
where.append('oim.indexer_configuration_id = ANY(%s)') | where.append('oim.indexer_configuration_id = ANY(%s)') | ||||
args.append(tool_ids) | args.append(tool_ids) | ||||
if where: | if where: | ||||
query_parts.append('WHERE') | query_parts.append('WHERE') | ||||
Show All 34 Lines |