fix: ensuring submitter email can be pulled from mpe_emails
All checks were successful
Release / Build-production-and-ng-test (push) Successful in 4m46s
Release / Build-and-test-development (push) Successful in 8m34s
Release / release (push) Successful in 6m51s

This commit is contained in:
zmaj 2024-02-02 11:20:43 +00:00
parent 1c8e4604de
commit eac0104d7a
2 changed files with 60 additions and 9 deletions

View File

@ -42,3 +42,42 @@ create table &dclib..mpe_xlmap_info(
tx_to num not null,
constraint pk_mpe_xlmap_info
primary key(tx_from,XLMAP_ID));
/* add mpe_tables entries */
insert into &dclib..mpe_tables
set tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,libref="&dclib"
,dsn='MPE_XLMAP_INFO'
,num_of_approvals_required=1
,loadtype='TXTEMPORAL'
,var_txfrom='TX_FROM'
,var_txto='TX_TO'
,buskey='XLMAP_ID'
,notes='Docs: https://docs.datacontroller.io/complex-excel-uploads'
,post_edit_hook='services/hooks/mpe_xlmap_info_postedit'
;
insert into &dclib..mpe_tables
set tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,libref="&dclib"
,dsn='MPE_XLMAP_RULES'
,num_of_approvals_required=1
,loadtype='TXTEMPORAL'
,var_txfrom='TX_FROM'
,var_txto='TX_TO'
,buskey='XLMAP_ID XLMAP_RANGE_ID'
,notes='Docs: https://docs.datacontroller.io/complex-excel-uploads'
,post_edit_hook='services/hooks/mpe_xlmap_rules_postedit'
;
insert into &dclib..mpe_tables
set tx_from=0
,tx_to='31DEC5999:23:59:59'dt
,libref="&dclib"
,dsn='MPE_XLMAP_DATA'
,num_of_approvals_required=1
,loadtype='UPDATE'
,buskey='LOAD_REF XLMAP_ID XLMAP_RANGE_ID ROW_NO COL_NO'
,notes='Docs: https://docs.datacontroller.io/complex-excel-uploads'
;

View File

@ -46,7 +46,7 @@
/* get users TO which the email should be sent */
proc sql noprint;
create table users as select distinct a.alert_user,
create table work.users as select distinct a.alert_user,
b.user_displayname,
b.user_email
from &mpelib..mpe_alerts
@ -58,16 +58,26 @@ create table users as select distinct a.alert_user,
and a.alert_lib in ("&alert_lib","*ALL*")
and a.alert_ds in ("&alert_ds","*ALL*");
%local isThere;
/* ensure the submitter is included on the email */
%local isThere userdisp user_eml;
%let isThere=0;
select count(*) into: isThere from &syslast where alert_user="&from_user";
%if &isThere>0 %then %do;
insert into &syslast set alert_user="&from_user";
%if &isThere=0 %then %do;
select user_displayname, user_email
into: userdisp trimmed, :user_eml trimmed
from &mpelib..mpe_emails
where &dc_dttmtfmt. lt tx_to
and user_name="&from_user";
insert into work.users
set alert_user="&from_user"
,user_displayname="&userdisp"
,user_email="&user_eml";
%end;
/* if no email / displayname is provided, then extract from metadata */
data emails;
set users;
data work.emails;
set work.users;
length emailuri uri text $256; call missing(emailuri,uri); drop emailuri uri;
/* get displayname */
@ -92,11 +102,13 @@ data emails;
end;
/* only keep valid emails */
if index(user_email,'@') ;
/* dump contents for debugging */
if _n_<21 then putlog (_all_)(=);
run;
%local emails;
proc sql noprint;
select user_email into: emails separated by '" "' from emails;
select quote(trim(user_email)) into: emails separated by ' ' from work.emails;
/* exit if nobody to email */
%if %mf_getattrn(emails,NLOBS)=0 %then %do;
@ -110,7 +122,7 @@ data _null_;
put optname '=' setting;
run;
filename __out email ("&emails")
filename __out email (&emails)
subject="Table &alert_lib..&alert_ds has been &alert_event";
%local SUBMITTED_TXT;
@ -172,4 +184,4 @@ filename __out email ("&emails")
filename __out clear;
%mend mpe_alerts ;
%mend mpe_alerts ;