from .engine import make as make_engine
from ..ut.connection import ccontext
from ..ut.guard import timeguard
from .. import db
from ..core.notice import send_notice


@timeguard
def notice_all(conf):
    engine = make_engine(conf)

    with ccontext(engine=engine) as conn:
        notices = db.get_pending_notices(conn)

    for notice in notices:
        with ccontext(commit=True, engine=engine) as conn:
            if db.email_activated_bi_id(conn, notice.email_id):
                send_notice(
                    conf=conf,
                    notice=notice,
                    conn=conn,
                )

@@ -406,76 +406,8 @@
 nn:%0A
-            if db.email_activated_bi_id(conn, notice.email_id):%0A    
     
@@ -443,20 +443,16 @@
         
-    
 conf=con
@@ -466,28 +466,24 @@
             
-  
-  
 notice=notic
@@ -501,20 +501,16 @@
         
-    
 conn=con
@@ -512,20 +512,16 @@
 n=conn,%0A
-    
         

fix email_id bug in notice task