0% found this document useful (0 votes)
6 views3 pages

Existing Interest Query

The document outlines a PHP script for querying and retrieving statistics related to projects and job applications in a Drupal environment. It includes access checks, conditions for filtering data, and formats the response in JSON with event statistics and counts of applications. The script also handles monthly data aggregation for job applications and returns a structured response indicating success.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Existing Interest Query

The document outlines a PHP script for querying and retrieving statistics related to projects and job applications in a Drupal environment. It includes access checks, conditions for filtering data, and formats the response in JSON with event statistics and counts of applications. The script also handles monthly data aggregation for job applications and returns a structured response indicating success.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

$existing_interest_query = \Drupal::entityTypeManager()

->getStorage('interested_project')
->getQuery()
->accessCheck(TRUE) // Explicitly set access check here.
// ->condition('user_id', $user->id())
->condition('project_id', $projectId)
->execute();

$applied_application_count = \Drupal::entityQuery('node')
->condition('type', 'applied_applications')
->condition('status', 1)
->condition('field_applied_status', 'collaborated')
->count()
->accessCheck(FALSE)
->execute();

"{
""status"": ""OK"",
""message"": "" Event statistic retrived successfully"",
""response"": {
""data"":[
{
""date"": ""16/12/2024"",
""name"": ""project"",
""totalValue"": 30,
""subcategories"": [
{
""name"": ""Project Interested"",
""value"": ""15""
},
{
""name"": ""c"",
""value"": ""15""
}
]
},
{
""date"": ""17/12/2024"",
""name"": ""project"",
""totalValue"": 30,
""subcategories"": [
{
""name"": ""Project Interested"",
""value"": ""15""
},
{
""name"": ""Project EOI submission"",
""value"": ""15""
}
]
},

]
}
}"

"is the common object


event:
{
""date"": ""filter type"",
""name"": ""Event"",
""totalValue"": 30,
""subcategories"": [
{
""name"": ""Event published"",
""value"": ""15""
},
{
""name"": ""Event add to calendar"",
""value"": ""15""
}
]
},

job:

{
""date"": ""filter type"",
""name"": ""job"",
""totalValue"": 30,
},"

case 'monthly':
// Group by each month.
//die($end_timestamp);
$end_timestamp = strtotime($endDate);
die($end_timestamp);
$current_month_start = strtotime('first day of this month 00:00:00',
$start_timestamp);
while ($current_month_start <= $end_timestamp) {
$month_start = $current_month_start;
$month_end = strtotime('last day of this month 23:59:59', $month_start);

$monthly_app_shortlisted_query = \Drupal::entityQuery('node')
->condition('type', 'applied_jobs')
// ->condition('created', $month_start, '>=')
->condition('created', min($month_end, $end_timestamp), '<=')
->condition('status', 1)
->condition('field_applied_status', 'collaborated')
->accessCheck(FALSE);
$monthly_app_shortlisted_count = count($monthly_app_shortlisted_query-
>execute());

$data[] = [
'date' => date('M', $month_start),
'name' => "job",
'totalValue'=> $monthly_app_shortlisted_count,
];
}

return new ResourceResponse([


'status' => 'OK',
'message' => 'Monthly Metric retrieved successfully',
'response' => [
'data' => $data,
],
], 200);
break;

You might also like