-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcron_job.php
34 lines (30 loc) · 1.02 KB
/
cron_job.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* Recommender Service for Morning Mail
*
* FILE: cron_job.php
* COURSE: Web Systems Development
* AUTHOR(s): Matt Perry
* DESCRIPTION:
* This script is meant to be run from a cron
* job every 24 hours
*/
require_once( "lib/api.php" );
$qt_days = 30;
$qt_threshold = 0.5;
$cleanup_count = Article::cleanup();
$new_article_count = Article::mm_update();
$cluster_start = time();
$clusters_made = count( QualityThreshold::cluster( $qt_days, $qt_threshold ) );
$cluster_runtime = time() - $cluster_start;
$cluster_write = QualityThreshold::save() ? 'true' : 'false';
$log_file = "log/cron_job.log";
$fh = fopen( $log_file, "a" ) or die( "Cannot open log file" );
$today = date( "Y-m-d H:i:s" );
fwrite( $fh, "cron_job.php: $today\n" );
fwrite( $fh, "Articles removed: $cleanup_count\n" );
fwrite( $fh, "Articles added: $new_article_count\n" );
fwrite( $fh, "Cluster runtime: $cluster_runtime seconds\n" );
fwrite( $fh, "Clusters made: $clusters_made\n" );
fwrite( $fh, "Cluster write successful: $cluster_write\n\n" );
?>