Repository navigation
Algorithm of the Prayer Stacker
Chris Chasm edited this page Nov 9, 2022
·
4 revisions
This is the logic flow for the algorithm to produce the list of randomized/personalized prayers and facts.
graph TD;
A[Location grid ID]-->B;
B[Builds Stacker - list of facts about the location]-->C;
C[Creates Customized Prayers for Concepts]-->D;
D[Shuffles Concepts Order]-->E;
E[Deduplicates List] -->F;
F[Reduces list to 8 elements] -->G;
G[Adds Facts into Specific Positions]-->H;
H[Clean and Return];
// get queries
$stack = self::_stack_query( $grid_id );
$stack['list'] = [];
$lists = [];
// PRAYER SHUFFLE
PG_Stacker_Text_V2::_for_movement( $lists, $stack );
PG_Stacker_Text_V2::_population_prayers( $lists, $stack );
PG_Stacker_Text_V2::_language_prayers( $lists, $stack );
PG_Stacker_Text_V2::_religion_prayers( $lists, $stack );
PG_Stacker_Text_V2::_for_prayer_movement( $lists, $stack );
PG_Stacker_Text_V2::_for_abundant_gospel_sowing( $lists, $stack );
PG_Stacker_Text_V2::_for_new_churches( $lists, $stack );
PG_Stacker_Text_V2::_for_obedience( $lists, $stack );
PG_Stacker_Text_V2::_for_biblical_authority( $lists, $stack );
PG_Stacker_Text_V2::_for_leadership( $lists, $stack );
PG_Stacker_Text_V2::_for_house_churches( $lists, $stack );
PG_Stacker_Text_V2::_for_multiplication( $lists, $stack );
PG_Stacker_Text_V2::_for_urgency( $lists, $stack );
PG_Stacker_Text_V2::_for_church_health( $lists, $stack );
// PG_Stacker_Text_V2::_cities($lists, $stack );
switch ( $stack['location']['favor'] ) {
case 'non_christians':
PG_Stacker_Text_V2::_non_christians( $lists, $stack );
break;
case 'christian_adherents':
PG_Stacker_Text_V2::_christian_adherents( $lists, $stack );
break;
case 'believers':
PG_Stacker_Text_V2::_believers( $lists, $stack );
break;
default:
break;
}
foreach ( $lists as $content ) { // kill duplication
$content['id'] = hash( 'sha256', serialize( $content ) . microtime() );
$stack['list'][$content['id']] = [
'type' => 'basic_block',
'data' => $content
];
}
shuffle( $stack['list'] );
$stack['list'] = array_slice( $stack['list'], 0, 8 );
// FACT SHUFFLE
self::_photos( $stack, 1 );
self::_faith_status( $stack, 3 );
self::_least_reached( $stack, 5 );
self::_people_groups( $stack, 7 );
self::_key_city( $stack, 9 );
// APPEND TO END
// self::_cities( $stack );
// REDUCE STACK
$reduced_stack = [];
$reduced_stack['list'] = $stack['list'];
$reduced_stack['location'] = $stack['location'];
$stack = $reduced_stack;
return $stack;