示例#1
0
    def build(cls, account, mode, section=None):
        status = SyncResult.get_latest(account, mode, section).first()

        if status is None or status.latest is None:
            return _('Not run yet.')

        # Build status fragments
        fragments = []

        if status.latest.ended_at:
            # Build "Last run [...] ago" fragment
            fragments.append(cls.build_since(status))

            if status.latest.started_at:
                # Build "taking [...] seconds" fragment
                fragments.append(cls.build_elapsed(status))

        # Build result fragment (success, errors)
        fragments.append(cls.build_result(status))

        # Merge fragments
        if len(fragments):
            return ', '.join(fragments) + '.'

        return _('Not run yet.')
示例#2
0
    def build(cls, account, mode, section=None):
        status = SyncResult.get_latest(account, mode, section).first()

        if status is None or status.latest is None:
            return _('Not run yet.')

        # Build status fragments
        fragments = []

        if status.latest.ended_at:
            # Build "Last run [...] ago" fragment
            fragments.append(cls.build_since(status))

            if status.latest.started_at:
                # Build "taking [...] seconds" fragment
                fragments.append(cls.build_elapsed(status))

        # Build result fragment (success, errors)
        fragments.append(cls.build_result(status))

        # Merge fragments
        if len(fragments):
            return ', '.join(fragments) + '.'

        return _('Not run yet.')
示例#3
0
    def get_last_result(cls, account, mode):
        status = (SyncStatus.select(SyncStatus.id).where(
            SyncStatus.account == account, SyncStatus.mode == mode,
            SyncStatus.section == None).first())

        if status is None:
            return None

        return (SyncResult.select(
            SyncResult.started_at,
            SyncResult.ended_at).where(SyncResult.status == status).order_by(
                SyncResult.ended_at.desc()).first())