Skip to content

Commit

Permalink
Merge pull request #31 from eduardo-paes:development
Browse files Browse the repository at this point in the history
Modify projects endpoints
  • Loading branch information
eduardo-paes authored Oct 28, 2023
2 parents af155e3 + e3e1d2d commit b0f0877
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 44 deletions.
Binary file added docs/images/apim_gpic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/demo_rate_limit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/seq_sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/Application/Mappings/ProjectMappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ public ProjectMappings()
{
_ = CreateMap<Project, OpenProjectInput>().ReverseMap();
_ = CreateMap<Project, UpdateProjectInput>().ReverseMap();
_ = CreateMap<Project, ResumedReadProjectOutput>().ReverseMap();
_ = CreateMap<Project, DetailedReadProjectOutput>().ReverseMap();
_ = CreateMap<Project, ResumedReadProjectOutput>()
.ForMember(dest => dest.ProfessorName, opt => opt.MapFrom(src => src.Professor.User.Name))

Check warning on line 15 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 15 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 15 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 15 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 15 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 15 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
.ForMember(dest => dest.StudentName, opt => opt.MapFrom(src => src.Student.User.Name))

Check warning on line 16 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 16 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 16 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 16 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 16 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 16 in src/Application/Mappings/ProjectMappings.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
.ReverseMap();

}
}
}
5 changes: 5 additions & 0 deletions src/Application/Ports/Project/BaseProjectContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@ public abstract class BaseProjectContract
public string? CancellationReason { get; set; }
public DateTime SendingDocumentationDeadline { get; set; }
#endregion Informações de Controle

#region Informações dos Envolvidos
public string? ProfessorName { get; set; }
public string? StudentName { get; set; }
#endregion Informações dos Envolvidos
}
}
66 changes: 23 additions & 43 deletions src/Infrastructure/Persistence/Repositories/ProjectRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,29 @@ public async Task<Project> DeleteAsync(Guid? id)

public async Task<IEnumerable<Project>> GetProfessorProjectsAsync(int skip, int take, Guid? id, bool isClosed = false)
{
return isClosed
? await _context.Projects
.Include(x => x.Student)
.Include(x => x.Professor)
.Include(x => x.SubArea)
.Include(x => x.ProgramType)
.Include(x => x.Notice)
.IgnoreQueryFilters()
.AsAsyncEnumerable()
.Where(x => x.ProfessorId == id
&& (x.Status == EProjectStatus.Closed
|| x.Status == EProjectStatus.Canceled))
.OrderByDescending(x => x.Notice?.RegistrationStartDate) // Traz os projetos mais recentes primeiro.
.ThenBy(x => x.Title) // Traz os projetos em ordem alfabética.
.Skip(skip)
.Take(take)
.ToListAsync()
: (IEnumerable<Project>)await _context.Projects
return await _context.Projects
.Include(x => x.Student)
.Include(x => x.Student!.User)
.Include(x => x.Professor)
.Include(x => x.Professor!.User)
.Include(x => x.SubArea)
.Include(x => x.ProgramType)
.Include(x => x.Notice)
.IgnoreQueryFilters()
.AsAsyncEnumerable()
.Where(x => x.ProfessorId == id
&& x.Status != EProjectStatus.Closed
&& x.Status != EProjectStatus.Canceled)
.OrderByDescending(x => x.Notice?.RegistrationStartDate) // Traz os projetos mais recentes primeiro.
.Where(x => WhereClause(id, x))
.OrderByDescending(x => (x.Notice?.RegistrationStartDate)) // Traz os projetos mais recentes primeiro.
.ThenBy(x => x.Title) // Traz os projetos em ordem alfabética.
.Skip(skip)
.Take(take)
.ToListAsync();

bool WhereClause(Guid? id, Project p)
{
return isClosed
? p.ProfessorId == id && (p.Status == EProjectStatus.Closed || p.Status == EProjectStatus.Canceled)
: p.ProfessorId == id && p.Status != EProjectStatus.Closed && p.Status != EProjectStatus.Canceled;
}
}

public async Task<IEnumerable<Project>> GetProjectsAsync(int skip, int take, bool isClosed = false)
Expand Down Expand Up @@ -123,39 +113,29 @@ public async Task<IEnumerable<Project>> GetProjectsAsync(int skip, int take, boo

public async Task<IEnumerable<Project>> GetStudentProjectsAsync(int skip, int take, Guid? id, bool isClosed = false)
{
return isClosed
? await _context.Projects
.Include(x => x.Student)
.Include(x => x.Professor)
.Include(x => x.SubArea)
.Include(x => x.ProgramType)
.Include(x => x.Notice)
.IgnoreQueryFilters()
.AsAsyncEnumerable()
.Where(x => x.StudentId == id
&& (x.Status == EProjectStatus.Closed
|| x.Status == EProjectStatus.Canceled))
.OrderByDescending(x => x.Notice?.RegistrationStartDate) // Traz os projetos mais recentes primeiro.
.ThenBy(x => x.Title) // Traz os projetos em ordem alfabética.
.Skip(skip)
.Take(take)
.ToListAsync()
: (IEnumerable<Project>)await _context.Projects
return await _context.Projects
.Include(x => x.Student)
.Include(x => x.Student!.User)
.Include(x => x.Professor)
.Include(x => x.Professor!.User)
.Include(x => x.SubArea)
.Include(x => x.ProgramType)
.Include(x => x.Notice)
.IgnoreQueryFilters()
.AsAsyncEnumerable()
.Where(x => x.StudentId == id
&& x.Status != EProjectStatus.Closed
&& x.Status != EProjectStatus.Canceled)
.Where(x => WhereClause(id, x))
.OrderByDescending(x => x.Notice?.RegistrationStartDate) // Traz os projetos mais recentes primeiro.
.ThenBy(x => x.Title) // Traz os projetos em ordem alfabética.
.Skip(skip)
.Take(take)
.ToListAsync();

bool WhereClause(Guid? id, Project p)
{
return isClosed
? p.StudentId == id && (p.Status == EProjectStatus.Closed || p.Status == EProjectStatus.Canceled)
: p.StudentId == id && p.Status != EProjectStatus.Closed && p.Status != EProjectStatus.Canceled;
}
}

public async Task<IEnumerable<Project>> GetProjectByNoticeAsync(Guid? noticeId)
Expand Down

0 comments on commit b0f0877

Please sign in to comment.