@@ -25,52 +25,6 @@ public function __construct() {
2525 \add_action ( 'rest_after_insert_prpl_recommendations ' , [ $ this , 'handle_creating_user_task ' ], 10 , 3 );
2626 }
2727
28- /**
29- * Get the points for a new task.
30- *
31- * @return int
32- */
33- public function calc_points_for_new_task () {
34- $ items = \progress_planner ()->get_suggested_tasks_db ()->get_tasks_by ( [ 'provider_id ' => 'user ' ] );
35-
36- // If this is the first user task ever, return 1.
37- if ( ! count ( $ items ) ) {
38- return 1 ;
39- }
40-
41- // Get the task IDs from the todos.
42- $ task_ids = array_column ( $ items , 'task_id ' );
43-
44- // Get the completed activities for this week that are in the todos.
45- $ activities = array_filter (
46- \progress_planner ()->get_activities__query ()->query_activities (
47- [
48- 'start_date ' => new \DateTime ( 'monday this week ' ),
49- 'end_date ' => new \DateTime ( 'sunday this week ' ),
50- 'category ' => 'suggested_task ' ,
51- 'type ' => 'completed ' ,
52- ]
53- ),
54- function ( $ activity ) use ( $ task_ids ) {
55- return in_array ( $ activity ->data_id , $ task_ids , true );
56- }
57- );
58-
59- // If there are completed todos this week, we already have set the golden task and it was completed.
60- if ( count ( $ activities ) ) {
61- return 0 ;
62- }
63-
64- // Check if there are already published user tasks with a points value other than 0.
65- foreach ( $ items as $ item ) {
66- if ( 'publish ' === $ item ['post_status ' ] && isset ( $ item ['points ' ] ) && $ item ['points ' ] !== 0 ) {
67- return 0 ;
68- }
69- }
70-
71- return 1 ;
72- }
73-
7428 /**
7529 * Maybe change the points of the first item in the todo list on Monday.
7630 *
0 commit comments