Example #1
0
def listSubs():
    defaults = [
        x.value
        for x in SiteMetadata.select().where(SiteMetadata.key == 'default')
    ]
    defaults = Sub.select(Sub.sid, Sub.name).where(Sub.sid << defaults)
    print("Default Subs: ")
    for i in defaults:
        print("  ", i.name)
Example #2
0
def subscribers(save):
    """Update subscriber counts for all the subs."""
    if save:
        print('Name                             Before   After')
    else:
        print('Name                            Current Correct')

    subs = Sub.select(Sub.sid, Sub.name, Sub.subscribers).order_by(Sub.name)
    for sub in subs:
        count = SubSubscriber.select().where(
            (SubSubscriber.sid == sub.sid)
            & (SubSubscriber.status == 1)).count()
        print(f'{sub.name:32}{sub.subscribers:7}{count:8}')
        if save:
            Sub.update(subscribers=SubSubscriber.select().where(
                (SubSubscriber.sid == sub.sid)
                & (SubSubscriber.status == 1)).count()).where(
                    Sub.sid == sub.sid).execute()