def retain_identities(self, retention_time): """Retain the identities in SortingHat based on the `retention_time` value declared in the setup.cfg. :param retention_time: maximum number of minutes wrt the current date to retain the SortingHat data """ enrich_es = self.conf['es_enrichment']['url'] sortinghat_db = self.db current_data_source = self.get_backend(self.backend_section) active_data_sources = self.config.get_active_data_sources() if retention_time is None: logger.debug("[identities retention] Retention policy disabled, no identities will be deleted.") return if retention_time <= 0: logger.debug("[identities retention] Retention time must be greater than 0.") return logger.info('[%s] identities retention start', self.backend_section) logger.info('[%s] populate identities index start', self.backend_section) # Upload the unique identities seen in the items to the index `grimoirelab_identities_cache` populate_identities_index(self.conf['es_enrichment']['url'], self.conf[self.backend_section]['enriched_index']) logger.info('[%s] populate identities index end', self.backend_section) # Delete the unique identities in SortingHat which have not been seen in # `grimoirelab_identities_cache` during the retention time, and delete the orphan # unique identities (those ones in SortingHat but not in `grimoirelab_identities_cache`) retain_identities(retention_time, enrich_es, sortinghat_db, current_data_source, active_data_sources)
def retain_identities(self, retention_time): """Retain the identities in SortingHat based on the `retention_time` value declared in the setup.cfg. :param retention_time: maximum number of minutes wrt the current date to retain the SortingHat data """ enrich_es = self.conf['es_enrichment']['url'] sortinghat_db = self.db current_data_source = self.get_backend(self.backend_section) active_data_sources = self.config.get_active_data_sources() if retention_time is None: logger.debug("[identities retention] Retention policy disabled, no identities will be deleted.") return if retention_time <= 0: logger.debug("[identities retention] Retention time must be greater than 0.") return retain_identities(retention_time, enrich_es, sortinghat_db, current_data_source, active_data_sources)