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 @@ -206,9 +206,6 @@ {'origin': origin, 'allowed_statuses': allowed_statuses, 'require_snapshot': require_snapshot}) - def person_get(self, person): - return self.post('person', {'person': person}) - def fetch_history_start(self, origin_id): return self.post('fetch_history/start', {'origin_id': origin_id}) 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 @@ -439,12 +439,6 @@ **decode_request(request))) -@app.route('/person', methods=['POST']) -@timed -def person_get(): - return encode_data(get_storage().person_get(**decode_request(request))) - - @app.route('/fetch_history', methods=['GET']) @timed def fetch_history_get(): diff --git a/swh/storage/db.py b/swh/storage/db.py --- a/swh/storage/db.py +++ b/swh/storage/db.py @@ -777,22 +777,6 @@ regexp=regexp, with_visit=with_visit, cur=cur) return cur.fetchone()[0] - person_cols = ['fullname', 'name', 'email'] - person_get_cols = person_cols + ['id'] - - def person_get(self, ids, cur=None): - """Retrieve the persons identified by the list of ids. - - """ - cur = self._cursor(cur) - - query = """SELECT %s FROM (VALUES %%s) as t(id) - LEFT JOIN person ON t.id = person.id - """ % ','.join('person.' + col for col in self.person_get_cols) - - yield from execute_values_generator( - cur, query, ((id,) for id in ids)) - release_add_cols = [ 'id', 'target', 'target_type', 'date', 'date_offset', 'date_neg_utc_offset', 'name', 'comment', 'synthetic', diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py --- a/swh/storage/in_memory.py +++ b/swh/storage/in_memory.py @@ -1480,22 +1480,6 @@ visits, key=lambda v: (v['date'], v['visit']), default=None) return self._convert_visit(visit) - def person_get(self, person): - """Return the persons identified by their ids. - - Args: - person: array of ids. - - Returns: - The array of persons corresponding of the ids. - - """ - for p in person: - if 0 <= (p - 1) < len(self._persons): - yield dict(self._persons[p - 1], id=p) - else: - yield None - def stat_counters(self): """compute statistics about the number of tuples in various tables @@ -1702,7 +1686,7 @@ self._objects[key].append(('person', person_id)) else: person_id = self._objects[key][0][1] - p = next(self.person_get([person_id])) + p = self._persons[person_id-1] person.update(p.items()) person['id'] = person_id diff --git a/swh/storage/storage.py b/swh/storage/storage.py --- a/swh/storage/storage.py +++ b/swh/storage/storage.py @@ -1547,20 +1547,6 @@ """ return db.origin_count(url_pattern, regexp, with_visit, cur) - @db_transaction_generator(statement_timeout=500) - def person_get(self, person, db=None, cur=None): - """Return the persons identified by their ids. - - Args: - person: array of ids. - - Returns: - The array of persons corresponding of the ids. - - """ - for person in db.person_get(person): - yield dict(zip(db.person_get_cols, person)) - @db_transaction() def origin_add(self, origins, db=None, cur=None): """Add origins to the storage 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 @@ -2134,44 +2134,6 @@ self.origin['url'], 999) self.assertIsNone(actual_origin_visit) - def test_person_get(self): - # given (person injection through revision for example) - self.storage.revision_add([self.revision]) - rev = list(self.storage.revision_get([self.revision['id']]))[0] - - id0 = rev['committer']['id'] - person0 = self.revision['committer'] - - id1 = rev['author']['id'] - person1 = self.revision['author'] - - # when - actual_persons = self.storage.person_get([id0, id1]) - - # then - expected_persons = [ - { - 'id': id0, - 'fullname': person0['fullname'], - 'name': person0['name'], - 'email': person0['email'], - }, - { - 'id': id1, - 'fullname': person1['fullname'], - 'name': person1['name'], - 'email': person1['email'], - } - ] - self.assertEqual(list(actual_persons), expected_persons) - - # when - actual_persons = self.storage.person_get([id1, id0]) - - # then - expected_persons.reverse() - self.assertEqual(list(actual_persons), expected_persons) - @settings(deadline=None) # this test is very slow @given(strategies.booleans()) def test_origin_visit_get_latest(self, use_url): @@ -2305,7 +2267,7 @@ origin_url, require_snapshot=True), ) - def test_person_get_fullname_unicity(self): + def test_person_fullname_unicity(self): # given (person injection through revisions for example) revision = self.revision @@ -2327,15 +2289,6 @@ self.assertEqual(revisions[0]['committer'], revisions[1]['committer']) - # check person_get return same result - person0 = list( - self.storage.person_get([revisions[0]['committer']['id']]))[0] - - person1 = list( - self.storage.person_get([revisions[1]['committer']['id']]))[0] - - self.assertEqual(person0, person1) - def test_snapshot_add_get_empty(self): origin_id = self.storage.origin_add_one(self.origin) origin_visit1 = self.storage.origin_visit_add(origin_id,