Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/db.py
Show First 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | def origin_intrinsic_metadata_search_fulltext(self, terms, *, limit, cur): | ||||
"LIMIT %s;" | "LIMIT %s;" | ||||
).format(keys=', '.join(keys), | ).format(keys=', '.join(keys), | ||||
regconfig=regconfig, | regconfig=regconfig, | ||||
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, cur): | self, start, end, limit, ids_only, mappings, tool_ids, cur): | ||||
if ids_only: | if ids_only: | ||||
keys = 'oim.origin_id' | keys = 'oim.origin_id' | ||||
else: | else: | ||||
keys = ', '.join(map(self._convert_key, | keys = ', '.join(map(self._convert_key, | ||||
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 start: | ||||
where.append('oim.origin_id >= %s') | where.append('oim.origin_id >= %s') | ||||
args.append(start) | args.append(start) | ||||
if end: | if end: | ||||
where.append('oim.origin_id <= %s') | where.append('oim.origin_id <= %s') | ||||
args.append(end) | 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: | |||||
where.append('oim.indexer_configuration_id = ANY(%s)') | |||||
args.append(tool_ids) | |||||
if where: | if where: | ||||
query_parts.append('WHERE') | query_parts.append('WHERE') | ||||
query_parts.append(' AND '.join(where)) | query_parts.append(' AND '.join(where)) | ||||
if limit: | if limit: | ||||
query_parts.append('LIMIT %s') | query_parts.append('LIMIT %s') | ||||
args.append(limit) | args.append(limit) | ||||
Show All 28 Lines |