-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal: Improve loading time in courseHome page - refs BT#21784 #5589
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
namespace Chamilo\CoreBundle\Entity; | ||
|
||
use ApiPlatform\Core\Serializer\Filter\GroupFilter; | ||
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; | ||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; | ||
use ApiPlatform\Metadata\ApiFilter; | ||
|
@@ -34,8 +35,9 @@ | |
#[ApiResource( | ||
operations: [ | ||
new Get( | ||
uriTemplate: '/sessions/{id}', | ||
normalizationContext: [ | ||
'groups' => ['session:read', 'session:item:read'], | ||
'groups' => ['session:basic'], | ||
], | ||
security: "is_granted('ROLE_ADMIN') or is_granted('VIEW', object)" | ||
), | ||
|
@@ -95,7 +97,7 @@ | |
new Post(security: "is_granted('ROLE_ADMIN')"), | ||
new Delete(security: "is_granted('DELETE', object)"), | ||
], | ||
normalizationContext: ['groups' => ['session:read']], | ||
normalizationContext: ['groups' => ['session:basic']], | ||
denormalizationContext: ['groups' => ['session:write']], | ||
security: "is_granted('ROLE_ADMIN')" | ||
)] | ||
|
@@ -104,9 +106,10 @@ | |
#[ORM\EntityListeners([SessionListener::class])] | ||
#[ORM\Entity(repositoryClass: SessionRepository::class)] | ||
#[UniqueEntity('title')] | ||
#[ApiFilter(filterClass: SearchFilter::class, properties: ['title' => 'partial'])] | ||
#[ApiFilter(filterClass: PropertyFilter::class)] | ||
#[ApiFilter(filterClass: OrderFilter::class, properties: ['id', 'title'])] | ||
#[ApiFilter(SearchFilter::class, properties: ['title' => 'partial'])] | ||
#[ApiFilter(PropertyFilter::class)] | ||
#[ApiFilter(OrderFilter::class, properties: ['id', 'title'])] | ||
#[ApiFilter(GroupFilter::class, arguments: ['parameterName' => 'groups'])] | ||
class Session implements ResourceWithAccessUrlInterface, Stringable | ||
{ | ||
public const READ_ONLY = 1; | ||
|
@@ -121,6 +124,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable | |
public const SESSION_ADMIN = 4; | ||
|
||
#[Groups([ | ||
'session:basic', | ||
'session:read', | ||
'session_rel_user:read', | ||
'session_rel_course_rel_user:read', | ||
|
@@ -147,6 +151,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable | |
mappedBy: 'session', | ||
targetEntity: SessionRelCourse::class, | ||
cascade: ['persist'], | ||
fetch: 'EXTRA_LAZY', | ||
orphanRemoval: true | ||
)] | ||
protected Collection $courses; | ||
|
@@ -161,6 +166,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable | |
mappedBy: 'session', | ||
targetEntity: SessionRelUser::class, | ||
cascade: ['persist', 'remove'], | ||
fetch: 'EXTRA_LAZY', | ||
orphanRemoval: true | ||
)] | ||
protected Collection $users; | ||
|
@@ -219,6 +225,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable | |
|
||
#[Assert\NotBlank] | ||
#[Groups([ | ||
'session:basic', | ||
'session:read', | ||
'session:write', | ||
'session_rel_course_rel_user:read', | ||
|
@@ -233,6 +240,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable | |
protected string $title; | ||
|
||
#[Groups([ | ||
'session:basic', | ||
'session:read', | ||
'session:write', | ||
])] | ||
|
@@ -250,11 +258,11 @@ class Session implements ResourceWithAccessUrlInterface, Stringable | |
#[ORM\Column(name: 'duration', type: 'integer', nullable: true)] | ||
protected ?int $duration = null; | ||
|
||
#[Groups(['session:read'])] | ||
#[Groups(['session:basic', 'session:read'])] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. |
||
#[ORM\Column(name: 'nbr_courses', type: 'integer', unique: false, nullable: false)] | ||
protected int $nbrCourses; | ||
|
||
#[Groups(['session:read'])] | ||
#[Groups(['session:basic', 'session:read'])] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. |
||
#[ORM\Column(name: 'nbr_users', type: 'integer', unique: false, nullable: false)] | ||
protected int $nbrUsers; | ||
|
||
|
@@ -263,6 +271,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable | |
protected int $nbrClasses; | ||
|
||
#[Groups([ | ||
'session:basic', | ||
'session:read', | ||
'session:write', | ||
])] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
El GroupFilter no está configurado en la clase Session. Entonces, no sería necesario pasarlo en params ya que estás poniendo el grupo en otro endpoint.
Aunque usar GroupFilter en Session sería una opción para no tener otro endpoint