mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #3902 from turbo124/v2
Update refresh route to filter all subqueries by updated_at
This commit is contained in:
commit
baf5f8f479
@ -1 +1 @@
|
||||
5.0.10
|
||||
5.0.12
|
@ -243,7 +243,7 @@ class LoginController extends BaseController
|
||||
public function refresh(Request $request)
|
||||
{
|
||||
$ct = CompanyUser::whereUserId(auth()->user()->id);
|
||||
return $this->listResponse($ct);
|
||||
return $this->refreshResponse($ct);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,6 +130,51 @@ class BaseController extends Controller
|
||||
return response()->make($error, $httpErrorCode, $headers);
|
||||
}
|
||||
|
||||
protected function refreshResponse($query)
|
||||
{
|
||||
$this->buildManager();
|
||||
|
||||
$transformer = new $this->entity_transformer(Input::get('serializer'));
|
||||
|
||||
$includes = $transformer->getDefaultIncludes();
|
||||
|
||||
$includes = $this->getRequestIncludes($includes);
|
||||
|
||||
$updated_at = request()->has('updated_at') ? request()->input('updated_at') : 0;
|
||||
$updated_at = date('Y-m-d H:i:s', $updated_at);
|
||||
|
||||
$query->with(
|
||||
[
|
||||
'company' => function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
||||
'company.activities' => function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
||||
'company.clients' =>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.tax_rates'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.groups'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.company_gateways'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.clients.contacts'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.products'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.invoices.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.invoices.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.invoices.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.payments.paymentables'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.quotes.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.quotes.documents'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.credits.invitations'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.credits'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.payment_terms'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.vendors'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.expenses'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.tasks'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.projects'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
'company.designs'=>function ($query) use($updated_at){$query->where('updated_at', '>', $updated_at);},
|
||||
]
|
||||
);
|
||||
|
||||
$data = $this->createCollection($query, $transformer, $this->entity_type);
|
||||
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
protected function listResponse($query)
|
||||
{
|
||||
$this->buildManager();
|
||||
|
@ -51,7 +51,7 @@ class QueryLogging
|
||||
// Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time);
|
||||
|
||||
//if($count > 10)
|
||||
// Log::info($queries);
|
||||
Log::info($queries);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class StoreWebhookRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'target_url' => 'required',
|
||||
'target_url' => 'required|url',
|
||||
'event_id' => 'required',
|
||||
];
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class UpdateWebhookRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'target_url' => 'url',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ class WebhookHandler implements ShouldQueue
|
||||
// generate JSON data
|
||||
$manager = new Manager();
|
||||
$manager->setSerializer(new ArraySerializer());
|
||||
$manager->parseIncludes($include);
|
||||
// $manager->parseIncludes($include);
|
||||
|
||||
$transformer = new $this->getTransformerClassName();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user