Skip to content

Commit 972f90b

Browse files
committed
fix: update election email spec logic
chore: update election email template Signed-off-by: [email protected] <[email protected]>
1 parent 263a1d7 commit 972f90b

File tree

4 files changed

+96
-106
lines changed

4 files changed

+96
-106
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,4 @@ registration/css
124124
/summit-trackchair-app/css/
125125
/.env
126126
/docker-compose/mysql/model/*.sql
127+
/docker-compose/mysql/model/

elections/code/infrastructure/repositories/SapphireFoundationMemberRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(){
3535
public function getMembersThatNotVotedOnLatestNElections($n, $limit, $offset, IElectionRepository $election_repository)
3636
{
3737
$specification = new FoundationMembershipRevocationSpecification;
38-
$sql = $specification->sql($n, $necessary_votes = 2 , $election_repository, $offset, $limit);
38+
$sql = $specification->sql($n, $election_repository, $offset, $limit);
3939
if(Director::is_cli()){
4040
fwrite
4141
(

elections/code/model/FoundationMembershipRevocationSpecification.php

Lines changed: 73 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -11,103 +11,80 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
**/
14+
1415
/**
1516
* Class FoundationMembershipRevocationSpecification
1617
*/
17-
final class FoundationMembershipRevocationSpecification {
18-
19-
/**
20-
* @param IFoundationMember $member
21-
* @param int $latest_elections_qty
22-
* @param int $necessary_votes
23-
* @param IElectionRepository $elections_repository
24-
* @param IVoteRepository $vote_repository
25-
* @return bool
26-
*/
27-
public function mustSendNotification(IFoundationMember $member, $latest_elections_qty, $necessary_votes, IElectionRepository $elections_repository, IVoteRepository $vote_repository){
28-
// must be a foundation member, otherwise, do not sent anything
29-
if(!$member->isFoundationMember()) return false;
30-
31-
$elections = $elections_repository->getLatestNElections($latest_elections_qty);
32-
33-
if(count($elections) == 0) return false;
34-
35-
$elections_id = [];
36-
$latest_election = $elections[0];
37-
$latest_election_id = $latest_election->getIdentifier();
38-
39-
foreach($elections as $election)
40-
array_push($elections_id, $election->getIdentifier());
41-
42-
// must not have pending revocation notifications , otherwise, do not sent anything
43-
if($member->hasPendingRevocationNotifications($latest_election_id)) return false;
44-
45-
return $vote_repository->getVotesCountByMemberAndElections($member->getIdentifier(), $elections_id) < $necessary_votes;
46-
47-
}
48-
49-
/**
50-
* @param int $latest_elections_qty
51-
* @param int $necessary_votes
52-
* @param IElectionRepository $elections_repository
53-
* @param int $offset
54-
* @param int $limit
55-
* @return bool|string
56-
*/
57-
public function sql($latest_elections_qty, $necessary_votes, IElectionRepository $elections_repository, $offset, $limit){
58-
59-
$elections = $elections_repository->getLatestNElections($latest_elections_qty);
60-
61-
if(count($elections) == 0) return false;
62-
63-
$elections_id = [];
64-
$latest_election = $elections[0];
65-
$latest_election_id = $latest_election->getIdentifier();
66-
67-
foreach($elections as $election)
68-
array_push($elections_id, $election->getIdentifier());
69-
70-
$elections_id = implode(',',$elections_id);
71-
$election_time_zone = $latest_election->getEntityTimeZone();
72-
$cut_date = new DateTime('2014-01-13', $election_time_zone);
73-
$election_open_date = new DateTime($latest_election->getElectionsOpen(), $election_time_zone);
74-
// @see https://chili.tipit.net/issues/7216#note-43
75-
if($election_open_date <= $cut_date) { // until January 2014
76-
$sql = <<<SQL
77-
-- members that did not vote on any latest election
78-
select DISTINCT M.ID from Member M
79-
inner join Group_Members gm on gm.MemberID = M.ID
80-
inner join `Group` g on g.ID = gm.GroupID and g.Code = 'foundation-members'
81-
inner join LegalAgreement la on la.MemberID = M.ID and la.LegalDocumentPageID = 422 and la.Created <= '2012-08-15 23:59:59'
82-
where not exists (
83-
select V.ID
84-
from ElectionVote V
85-
inner join Election E on V.ElectionID = E.ID
86-
where E.ID in ({$elections_id}) and V.VoterID = M.ID-- latest elections
87-
)
88-
and not exists(select id from FoundationMemberRevocationNotification rn where rn.RecipientID = M.ID and rn.Action = 'None') -- there is not any pending notification
89-
and not exists(select id from FoundationMemberRevocationNotification rn where rn.RecipientID = M.ID and rn.Action = 'Renew' and rn.LastElectionID = {$latest_election_id}) -- there are not rewnews for the current election
90-
limit {$offset},{$limit};
91-
92-
SQL;
93-
return $sql;
94-
}
95-
else if($election_open_date > $cut_date){ // newer elections -- moving forward for all future elections after Jan. 2015
96-
97-
// All members that joined on or before (180 days before the ElectionClose date of the earliest election
98-
// that has occurred in the last 2 years) have voted in none of the last two elections
99-
// (OUR PURGE LIST - GET AN EMAIL)
100-
$early_election = $elections_repository->getEarliestElectionSince(2);
101-
$early_election_time_zone = $latest_election->getEntityTimeZone();
102-
$early_election_local_close_date = new DateTime($early_election->getElectionsClose(), $early_election_time_zone);
103-
$serve_time_zone = new DateTimeZone(SERVER_TIME_ZONE);
104-
$early_election_server_close_date = $early_election_local_close_date->setTimezone($serve_time_zone)->format("Y-m-d H:i:s");
105-
$sql = <<<SQL
18+
final class FoundationMembershipRevocationSpecification
19+
{
20+
21+
/**
22+
* @param IFoundationMember $member
23+
* @param int $latest_elections_qty
24+
* @param int $necessary_votes
25+
* @param IElectionRepository $elections_repository
26+
* @param IVoteRepository $vote_repository
27+
* @return bool
28+
*/
29+
public function mustSendNotification(IFoundationMember $member, $latest_elections_qty, $necessary_votes, IElectionRepository $elections_repository, IVoteRepository $vote_repository)
30+
{
31+
// must be a foundation member, otherwise, do not sent anything
32+
if (!$member->isFoundationMember()) return false;
33+
34+
$elections = $elections_repository->getLatestNElections($latest_elections_qty);
35+
36+
if (count($elections) == 0) return false;
37+
38+
$elections_id = [];
39+
$latest_election = $elections[0];
40+
$latest_election_id = $latest_election->getIdentifier();
41+
42+
foreach ($elections as $election)
43+
array_push($elections_id, $election->getIdentifier());
44+
45+
// must not have pending revocation notifications , otherwise, do not sent anything
46+
if ($member->hasPendingRevocationNotifications($latest_election_id)) return false;
47+
48+
return $vote_repository->getVotesCountByMemberAndElections($member->getIdentifier(), $elections_id) < $necessary_votes;
49+
50+
}
51+
52+
/**
53+
* @param int $latest_elections_qty
54+
* @param IElectionRepository $elections_repository
55+
* @param int $offset
56+
* @param int $limit
57+
* @return bool|string
58+
*/
59+
public function sql(int $latest_elections_qty, IElectionRepository $elections_repository, int $offset, int $limit)
60+
{
61+
62+
$elections = $elections_repository->getLatestNElections($latest_elections_qty);
63+
64+
if (count($elections) == 0) return false;
65+
66+
$elections_id = [];
67+
$latest_election = $elections[0];
68+
$latest_election_id = $latest_election->getIdentifier();
69+
70+
foreach ($elections as $election)
71+
$elections_id[] = $election->getIdentifier();
72+
73+
$elections_id = implode(',', $elections_id);
74+
// All members that joined on or before (180 days before the ElectionClose date of the earliest election
75+
// that has occurred in the last year) have voted in none of the last two elections
76+
// (OUR PURGE LIST - GET AN EMAIL)
77+
$latest_election_time_zone = $latest_election->getEntityTimeZone();
78+
$latest_election_local_close_date = new DateTime($latest_election->getElectionsClose(), $latest_election_time_zone);
79+
$serve_time_zone = new DateTimeZone(SERVER_TIME_ZONE);
80+
$latest_election_server_close_date = $latest_election_local_close_date->setTimezone($serve_time_zone)->format("Y-m-d H:i:s");
81+
82+
$sql = <<<SQL
10683
-- members that did not vote on any latest election
10784
SELECT DISTINCT M.ID FROM Member M
10885
inner join Group_Members gm on gm.MemberID = M.ID
10986
inner join `Group` g on g.ID = gm.GroupID and g.Code = 'foundation-members'
110-
inner join LegalAgreement la on la.MemberID = M.ID and la.LegalDocumentPageID = 422 and la.Created <= date_add('{$early_election_server_close_date}', interval -180 day)
87+
inner join LegalAgreement la on la.MemberID = M.ID and la.LegalDocumentPageID = 422 and la.Created <= date_add('{$latest_election_server_close_date}', interval -180 day)
11188
where not exists (
11289
select V.ID
11390
from ElectionVote V
@@ -118,8 +95,10 @@ public function sql($latest_elections_qty, $necessary_votes, IElectionRepository
11895
and not exists(select id from FoundationMemberRevocationNotification rn where rn.RecipientID = M.ID and rn.Action = 'Renew' and rn.LastElectionID = {$latest_election_id}) -- there are not renew for the current election
11996
limit {$offset},{$limit};
12097
SQL;
121-
return $sql;
122-
}
123-
return false;
124-
}
98+
99+
SS_Log::log(sprintf("FoundationMembershipRevocationSpecification::sql latest_elections_qty %s sql %s", $sql, $latest_elections_qty),SS_Log::NOTICE);
100+
101+
return $sql;
102+
103+
}
125104
}

elections/templates/Layout/Includes/RevocationNotificationEmail.ss

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
<p>Dear Foundation Member,</p>
2-
<p>According to our records, you haven't voted in at least half of the Foundation elections in the past 2 years. Per the bylaws,
3-
your membership will be suspended effective 30 days from now, on {$ExpirationDate}. This email serves as notice.</p>
4-
<p>If you wish to remain a Member of the OpenInfra Foundation you have until {$ExpirationDate} to make that request to
5-
the Secretary by visiting this page: <a href="{$TakeActionLink}">$TakeActionLink</a>.</p>
6-
<p>If you take no action, we will automatically change your account status from "Foundation Member" to "Community Member".
7-
As a "Community Member" you can continue to engage in many activities on openstack.org and openinfra.dev including s
8-
submitting talks for OpenInfra Summits. However, you will not have all of the rights and responsibilities of being
9-
a full Foundation Member, including voting in future Board of Directors elections.</p>
10-
<p>If you wish to remain a Foundation Member, you have until {$ExpirationDate} to request that the Secretary reinstate
11-
your account. You also have the option to delete your account entirely. Either option may be selected on this page
12-
prior to the deadline: <a href="{$TakeActionLink}">$TakeActionLink</a>.</p>
2+
<p>
3+
According to our records, you haven't voted in at least half of the Foundation elections in the past 2 years. Per the bylaws,
4+
your membership will be suspended effective 30 days from now, on {$ExpirationDate}.. This email serves as notice.
5+
</p>
6+
<p>
7+
If you wish to remain a Member of the OpenInfra Foundation you have until {$ExpirationDate} to make that request to
8+
the Secretary by visiting this page: <a href="{$TakeActionLink}">$TakeActionLink</a>.
9+
</p>
10+
<p>
11+
If you take no action, we will automatically change your account status from "Foundation Member" to "Community Member".
12+
As a "Community Member" you can continue to engage in many activities on openstack.org and openinfra.org including submitting
13+
talks for OpenInfra Summits. However, you will not have all of the rights and responsibilities of being a
14+
full Foundation Member, including voting in future Board of Directors elections.
15+
</p>
16+
17+
<p>
18+
If you wish to remain a Foundation Member, you have until April 3 to request that the Secretary reinstate your account.
19+
You also have the option to delete your account entirely. Either option may be selected on this page prior to the
20+
deadline: <a href="{$TakeActionLink}">$TakeActionLink</a>.
21+
</p>
22+
1323
<p>Jonathan Bryce
1424
<br/>Executive Director and Secretary, OpenInfra Foundation<br/>
1525
<a class="email" href="mailto:[email protected]">[email protected]</a>

0 commit comments

Comments
 (0)