@@ -84,7 +84,10 @@ sub _get_data_sources {
84
84
);
85
85
# Special case: include_file is not paragraph.
86
86
if ($ptype eq ' include_file' ) {
87
- @config = map { {name => $_ , path => $_ } } @config ;
87
+ @config = map {
88
+ my $name = substr [split m { /} , $_ ]-> [-1], 0, 15;
89
+ {name => $name , path => $_ };
90
+ } @config ;
88
91
}
89
92
my $type = $config_user_map {$ptype };
90
93
push @dss , map {
@@ -102,7 +105,10 @@ sub _get_data_sources {
102
105
map { @{$_ -> {$ptype } || []} } @config_files ;
103
106
# Special case: include_file is not paragraph.
104
107
if ($ptype eq ' include_file' ) {
105
- @config = map { {name => $_ , path => $_ } } @config ;
108
+ @config = map {
109
+ my $name = substr [split m { /} , $_ ]-> [-1], 0, 15;
110
+ {name => $name , path => $_ };
111
+ } @config ;
106
112
}
107
113
my $type = $config_user_map {$ptype };
108
114
push @dss , map {
@@ -204,7 +210,7 @@ sub _twist {
204
210
# III. Expire outdated entries.
205
211
206
212
# Choose most earlier time of succeeding inclusions (if any of
207
- # data sources have not succeeded yet, Unix epoch will be chosen ).
213
+ # data sources have not succeeded yet, time is not defined ).
208
214
$last_start_time = $start_time ;
209
215
foreach my $id (map { $_ -> get_short_id } @$dss ) {
210
216
unless (defined $start_times {$id }) {
@@ -365,6 +371,9 @@ sub __update_user {
365
371
# 3. If user (has not been updated by the other data sources and) exists:
366
372
# UPDATE inclusion.
367
373
if ($is_external_ds ) {
374
+ # Already updated by the other non-external data source but not yet
375
+ # by any other external ones:
376
+ # Update inclusion_ext (and inclusion) field, but not inclusion_label.
368
377
return unless $sth = $sdm -> do_prepared_query(
369
378
qq{ UPDATE ${t} _table
370
379
SET inclusion_$t = ?, inclusion_ext_$t = ?
@@ -376,28 +385,37 @@ sub __update_user {
376
385
);
377
386
return (updated => 0) if $sth -> rows;
378
387
388
+ # Not yet updated by any other data sources:
389
+ # Update inclusion_ext (and inclusion), and assign inclusion_label.
379
390
return unless $sth = $sdm -> do_prepared_query(
380
391
qq{ UPDATE ${t} _table
381
- SET inclusion_$t = ?, inclusion_ext_$t = ?
392
+ SET inclusion_$t = ?, inclusion_ext_$t = ?,
393
+ inclusion_label_$t = ?,
382
394
WHERE user_$t = ? AND list_$t = ? AND robot_$t = ?$r } ,
383
395
$time , $time ,
396
+ $ds -> name,
384
397
$email , $list -> {' name' }, $list -> {' domain' }
385
398
);
386
399
return (updated => 1) if $sth -> rows;
387
400
} else {
401
+ # Not yet updated by any other data sources:
402
+ # Update inclusion, and assign inclusion_label.
388
403
return unless $sth = $sdm -> do_prepared_query(
389
404
qq{ UPDATE ${t} _table
390
- SET inclusion_$t = ?
405
+ SET inclusion_$t = ?,
406
+ inclusion_label_$t = ?
391
407
WHERE user_$t = ? AND list_$t = ? AND robot_$t = ?$r } ,
392
408
$time ,
409
+ $ds -> name,
393
410
$email , $list -> {' name' }, $list -> {' domain' }
394
411
);
395
412
return (updated => 1) if $sth -> rows;
396
413
}
397
414
398
415
# 4. Otherwise, i.e. a new user:
399
416
# INSERT new user with:
400
- # email, gecos, subscribed=0, date, update, inclusion and
417
+ # email, gecos, subscribed=0, date, update, inclusion,
418
+ # (optional) inclusion_ext, inclusion_label and
401
419
# default attributes.
402
420
my $user = {
403
421
email => $email ,
@@ -407,6 +425,7 @@ sub __update_user {
407
425
update_date => $time ,
408
426
inclusion => $time ,
409
427
($is_external_ds ? (inclusion_ext => $time ) : ()),
428
+ inclusion_label => $ds -> name,
410
429
};
411
430
my @defkeys = @{$ds -> {_defkeys } || []};
412
431
my @defvals = @{$ds -> {_defvals } || []};
@@ -487,7 +506,8 @@ sub _expire_users {
487
506
unless (
488
507
$sdm -> do_prepared_query(
489
508
qq{ UPDATE ${t} _table
490
- SET inclusion_$t = NULL, inclusion_ext_$t = NULL
509
+ SET inclusion_$t = NULL, inclusion_ext_$t = NULL,
510
+ inclusion_label_$t = NULL
491
511
WHERE subscribed_$t = 1 AND
492
512
inclusion_$t IS NOT NULL AND inclusion_$t < ? AND
493
513
list_$t = ? AND robot_$t = ?$r } ,
0 commit comments