diff --git a/sql/swh-func.sql b/sql/swh-func.sql --- a/sql/swh-func.sql +++ b/sql/swh-func.sql @@ -1047,22 +1047,6 @@ left join person c on c.id = r.committer; $$; --- Retrieve a release by occurrence criterion -create or replace function swh_release_get_by( - origin_id bigint) - returns setof release_entry - language sql - stable -as $$ - select r.id, r.target, r.target_type, r.date, r.date_offset, r.date_neg_utc_offset, - r.name, r.comment, r.synthetic, a.id as author_id, a.fullname as author_fullname, - a.name as author_name, a.email as author_email, r.object_id - from release r - inner join occurrence_history occ on occ.target = r.target - left join person a on a.id = r.author - where occ.origin = origin_id and occ.target_type = 'revision' and r.target_type = 'revision'; -$$; - -- Create entries in entity_history from tmp_entity_history -- -- TODO: do something smarter to compress the entries if the data diff --git a/sql/swh-schema.sql b/sql/swh-schema.sql --- a/sql/swh-schema.sql +++ b/sql/swh-schema.sql @@ -14,7 +14,7 @@ ); insert into dbversion(version, release, description) - values(120, now(), 'Work In Progress'); + values(121, now(), 'Work In Progress'); -- a SHA1 checksum (not necessarily originating from Git) create domain sha1 as bytea check (length(value) = 20); diff --git a/sql/upgrades/121.sql b/sql/upgrades/121.sql new file mode 100644 --- /dev/null +++ b/sql/upgrades/121.sql @@ -0,0 +1,9 @@ +-- SWH DB schema upgrade +-- from_version: 120 +-- to_version: 121 +-- description: Drop unused function swh_release_get_by + +insert into dbversion(version, release, description) + values(121, now(), 'Work In Progress'); + +DROP FUNCTION swh_release_get_by(origin_id bigint); diff --git a/swh/storage/api/client.py b/swh/storage/api/client.py --- a/swh/storage/api/client.py +++ b/swh/storage/api/client.py @@ -86,10 +86,6 @@ def release_get(self, releases): return self.post('release', {'releases': releases}) - def release_get_by(self, origin_id, limit=None): - return self.post('release/by', dict(origin_id=origin_id, - limit=limit)) - def release_missing(self, releases): return self.post('release/missing', {'releases': releases}) diff --git a/swh/storage/api/server.py b/swh/storage/api/server.py --- a/swh/storage/api/server.py +++ b/swh/storage/api/server.py @@ -180,11 +180,6 @@ return encode_data(get_storage().release_get(**decode_request(request))) -@app.route('/release/by', methods=['POST']) -def release_get_by(): - return encode_data(get_storage().release_get_by(**decode_request(request))) - - @app.route('/release/missing', methods=['POST']) def release_missing(): return encode_data(get_storage().release_missing( diff --git a/swh/storage/db.py b/swh/storage/db.py --- a/swh/storage/db.py +++ b/swh/storage/db.py @@ -960,25 +960,6 @@ """ % query_keys, ((id,) for id in releases)) - def release_get_by(self, - origin_id, - limit=None, - cur=None): - """Retrieve a release by occurrence criterion (only origin right now) - - Args: - - origin_id: The origin to look for. - - """ - cur = self._cursor(cur) - query = """ - SELECT %s - FROM swh_release_get_by(%%s) - LIMIT %%s - """ % ', '.join(self.release_get_cols) - cur.execute(query, (origin_id, limit)) - yield from cursor_to_bytes(cur) - def revision_get_by(self, origin_id, branch_name, diff --git a/swh/storage/storage.py b/swh/storage/storage.py --- a/swh/storage/storage.py +++ b/swh/storage/storage.py @@ -1037,26 +1037,6 @@ continue yield data - @db_transaction_generator(statement_timeout=500) - def release_get_by(self, origin_id, limit=None, db=None, cur=None): - """Given an origin id, return all the tag objects pointing to heads of - origin_id. - - Args: - origin_id: the origin to filter on. - limit: None by default - - Yields: - List of releases matching the criterions or None if nothing is - found. - - """ - for line in db.release_get_by(origin_id, limit=limit, cur=cur): - data = converters.db_to_release( - dict(zip(db.release_get_cols, line)) - ) - yield data - @db_transaction(statement_timeout=2000) def object_find_by_sha1_git(self, ids, db=None, cur=None): """Return the objects found with the given ids. diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py --- a/swh/storage/tests/test_storage.py +++ b/swh/storage/tests/test_storage.py @@ -1239,36 +1239,6 @@ self.normalize_entity(self.release2)], [actual_releases[0], actual_releases[1]]) - @istest - def release_get_by(self): - # given - self.storage.revision_add([self.revision2]) # points to self.dir - self.storage.release_add([self.release3]) - origin_id = self.storage.origin_add_one(self.origin2) - - # occurrence2 points to 'revision2' with branch 'master', we - # need to point to the right origin - origin_visit = self.storage.origin_visit_add(origin_id, - self.date_visit2) - occurrence2 = self.occurrence2.copy() - occurrence2.update({ - 'origin': origin_id, - 'visit': origin_visit['visit'], - }) - - self.storage.occurrence_add([occurrence2]) - - # we want only revision 2 - expected_releases = list(self.storage.release_get( - [self.release3['id']])) - - # when - actual_results = list(self.storage.release_get_by( - occurrence2['origin'])) - - # then - self.assertEqual(actual_results[0], expected_releases[0]) - @istest def origin_add_one(self): origin0 = self.storage.origin_get(self.origin)