def store_record(cls, data): """Store new record and update old ones. :param data: dict, describing github data :return: boolean based on completion of process """ git_url = data.get("git_url", None) if git_url is None: logger.info("github Url not found") raise Exception("github Url not found") try: session = get_session() check_existing = cls.get_info(git_url) if check_existing["is_valid"]: cls._update_data(session, data) return check_existing["data"] entry = OSIORegisteredRepos( git_url=data['git_url'], git_sha=data['git_sha'], email_ids=data['email_ids'], last_scanned_at=datetime.datetime.now()) session.add(entry) session.commit() except SQLAlchemyError: session.rollback() raise Exception("Error in storing the record in current session") except Exception as e: raise Exception("Error in storing the record due to {}".format(e)) return cls.get_info(data["git_url"])
def store_record(cls, data): """Store new record in the database. :param data: dict, describing github data :return: boolean based on completion of process """ git_url = data.get("git-url", None) if git_url is None: logger.info("github Url not found") raise Exception("github Url not found") try: session = get_session() entry = OSIORegisteredRepos( git_url=data['git-url'], git_sha=data['git-sha'], email_ids=data.get('email-ids', 'dummy'), last_scanned_at=datetime.datetime.now()) add_entry_to_osio_registered_repos(session, entry) session.commit() except SQLAlchemyError: session.rollback() raise Exception("Error in storing the record in current session") except Exception as e: raise Exception("Error in storing the record due to {}".format(e)) return cls.get_info(data["git-url"])
def persist_repo_in_db(data): try: req = OSIORegisteredRepos(github_repo=data['github_repo'], github_sha=data['github_sha'], email_ids=data['email_ids']) _session.add(req) _session.commit() except SQLAlchemyError as e: message = 'persisting records in the database failed. {}.'.format(e) logger.exception(message) return {'message': message} return True