mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 07:10:29 -04:00
Change 'timestamp' properties on objects to more descriptive names
This commit is contained in:
parent
18f761929a
commit
dbefba6b94
32 changed files with 74 additions and 74 deletions
|
@ -3,5 +3,5 @@
|
|||
require_once('/standardebooks.org/web/lib/Core.php');
|
||||
|
||||
// Delete unconfirmed newsletter subscribers who are more than a week old
|
||||
Db::Query('DELETE from NewsletterSubscribers where IsConfirmed = false and datediff(utc_timestamp(), Timestamp) >= 7');
|
||||
Db::Query('DELETE from NewsletterSubscribers where IsConfirmed = false and datediff(utc_timestamp(), Created) >= 7');
|
||||
?>
|
||||
|
|
|
@ -57,8 +57,8 @@ foreach($contentFiles as $path){
|
|||
|
||||
$ebook = new Ebook($ebookWwwFilesystemPath);
|
||||
|
||||
$allEbooks[$ebook->ModifiedTimestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
|
||||
$newestEbooks[$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
|
||||
$allEbooks[$ebook->Modified->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
|
||||
$newestEbooks[$ebook->Created->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
|
||||
|
||||
foreach($ebook->Tags as $tag){
|
||||
// Add the book's subjects to the main subjects list
|
||||
|
@ -67,7 +67,7 @@ foreach($contentFiles as $path){
|
|||
}
|
||||
|
||||
// Sort this ebook by subject
|
||||
$ebooksBySubject[$tag->Name][$ebook->Timestamp->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
|
||||
$ebooksBySubject[$tag->Name][$ebook->Created->format('Y-m-d\TH:i:s\Z') . ' ' . $ebook->Identifier] = $ebook;
|
||||
}
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
|
|
|
@ -133,7 +133,7 @@ try{
|
|||
$payment->User = null;
|
||||
}
|
||||
|
||||
$payment->Timestamp = DateTime::createFromFormat('n/j/Y', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Created On"]]'))->getText()));
|
||||
$payment->Created = DateTime::createFromFormat('n/j/Y', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Created On"]]'))->getText()));
|
||||
$payment->TransactionId = trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "ID"]]'))->getText());
|
||||
$payment->IsRecurring = sizeof($headerRow->findElements(WebDriverBy::xpath('//td[contains(., "Recurring")]'))) > 0;
|
||||
$payment->Amount = floatval(str_replace('$', '', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Total Amount"]]'))->getText())));
|
||||
|
@ -157,7 +157,7 @@ try{
|
|||
|
||||
// If this payment isn't anonymous, does it put us in the Patrons Circle?
|
||||
if($payment->User !== null){
|
||||
if(($payment->IsRecurring && $payment->Amount >= 10 && $payment->Timestamp >= $lastMonth) || ($payment->Amount >= 100 && $payment->Timestamp >= $lastYear)){
|
||||
if(($payment->IsRecurring && $payment->Amount >= 10 && $payment->Created >= $lastMonth) || ($payment->Amount >= 100 && $payment->Created >= $lastYear)){
|
||||
// This payment is eligible for the Patrons Circle.
|
||||
// Are we already a patron?
|
||||
try{
|
||||
|
@ -170,7 +170,7 @@ try{
|
|||
$patron->User = $payment->User;
|
||||
}
|
||||
|
||||
if($patron->Timestamp === null || $patron->DeactivatedTimestamp !== null){
|
||||
if($patron->Created === null || $patron->Ended !== null){
|
||||
// If we're a new patron, or an old patron that was deactivated,
|
||||
// re-enable them as a patron in the system
|
||||
$patron->IsAnonymous = (trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Attribution"]]'))->getText()) == 'Private');
|
||||
|
@ -182,11 +182,11 @@ try{
|
|||
catch(Exception $ex){
|
||||
}
|
||||
|
||||
if($patron->Timestamp === null){
|
||||
if($patron->Created === null){
|
||||
$log->Write('Adding donor as patron ...');
|
||||
$patron->Create();
|
||||
}
|
||||
elseif($patron->DeactivatedTimestamp !== null){
|
||||
elseif($patron->Ended !== null){
|
||||
$log->Write('Reactivating donor as patron ...');
|
||||
$patron->Reactivate();
|
||||
}
|
||||
|
|
|
@ -8,16 +8,16 @@ require_once('/standardebooks.org/web/lib/Core.php');
|
|||
|
||||
Db::Query('
|
||||
update Patrons
|
||||
set DeactivatedTimestamp = utc_timestamp()
|
||||
set Ended = utc_timestamp()
|
||||
where UserId not in
|
||||
(
|
||||
select distinct UserId from Payments where
|
||||
UserId is not null
|
||||
and
|
||||
(
|
||||
(IsRecurring = 1 and Amount >= 10 and Timestamp > utc_timestamp() - interval 45 day)
|
||||
(IsRecurring = 1 and Amount >= 10 and Created > utc_timestamp() - interval 45 day)
|
||||
or
|
||||
(IsRecurring = 0 and Amount >= 100 and Timestamp > utc_timestamp() - interval 1 year)
|
||||
(IsRecurring = 0 and Amount >= 100 and Created > utc_timestamp() - interval 1 year)
|
||||
)
|
||||
)
|
||||
');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue