Example #1
0
def _sync_stories(guid, project, session):
    stories = remote.get_stories(guid, project.id)
    LOGGER.info("Scanning %d stories", len(stories))
    for story in stories:
        db_story = _to_orm(story, types.Story, {'requested_by': None, 'owned_by': None, 'labels': [], 'notes': []})
        try:
            db_story = session.merge(db_story)
        except exc.IntegrityError, e:
            LOGGER.error("Failed to save story %d: %s", story.id, e)
            session.rollback()
            continue
        db_story.labels = list(session.query(types.Label).filter(types.Label.name.in_(story.labels)))
        try:
            db_story.requested_by = session.query(types.User).filter(types.User.name==story.requested_by)[0]
        except IndexError:
            db_requested_by = types.User(name=story.requested_by)
            session.add(db_requested_by)
            db_story.requested_by = db_requested_by
        if story.owned_by:
            try:
                db_story.owned_by = session.query(types.User).filter(types.User.name==story.owned_by)[0]
            except IndexError:
                db_owned_by = types.User(name=story.owned_by)
                session.add(db_owned_by)
                db_story.owned_by = db_owned_by
        activities = remote.get_activities(guid, story.id)
        LOGGER.info("Scanning %d activities", len(activities))
        for activity in activities:
            db_activity = _to_orm(activity, types.Activity)
            try:
                db_activity = session.merge(db_activity)
            except exc.IntegrityError, e:
                LOGGER.error("Failed to save activity %d: %s", activity.id, e)
                session.rollback()
Example #2
0
def _sync_stories(guid, project, session):
    stories = remote.get_stories(guid, project.id)
    LOGGER.info("Scanning %d stories", len(stories))
    for story in stories:
        db_story = _to_orm(story, types.Story, {
            'requested_by': None,
            'owned_by': None,
            'labels': [],
            'notes': []
        })
        try:
            db_story = session.merge(db_story)
        except exc.IntegrityError, e:
            LOGGER.error("Failed to save story %d: %s", story.id, e)
            session.rollback()
            continue
        db_story.labels = list(
            session.query(types.Label).filter(
                types.Label.name.in_(story.labels)))
        try:
            db_story.requested_by = session.query(
                types.User).filter(types.User.name == story.requested_by)[0]
        except IndexError:
            db_requested_by = types.User(name=story.requested_by)
            session.add(db_requested_by)
            db_story.requested_by = db_requested_by
        if story.owned_by:
            try:
                db_story.owned_by = session.query(
                    types.User).filter(types.User.name == story.owned_by)[0]
            except IndexError:
                db_owned_by = types.User(name=story.owned_by)
                session.add(db_owned_by)
                db_story.owned_by = db_owned_by
        activities = remote.get_activities(guid, story.id)
        LOGGER.info("Scanning %d activities", len(activities))
        for activity in activities:
            db_activity = _to_orm(activity, types.Activity)
            try:
                db_activity = session.merge(db_activity)
            except exc.IntegrityError, e:
                LOGGER.error("Failed to save activity %d: %s", activity.id, e)
                session.rollback()
Example #3
0
def stories(guid, project_id):
    stories = remote.get_stories(guid, project_id)
    logging.info("%s stories", len(stories))