#28-Change database request
This commit is contained in:
parent
9ab0d9cee0
commit
1cd0f3fe31
@ -1,18 +1,19 @@
|
||||
package ru.ulstu.extractor.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class CommitTimeStatistic {
|
||||
private Date date;
|
||||
private Long countCommit;
|
||||
private final static String DATE_TEMPLATE = "%s.%s";
|
||||
private final int month;
|
||||
private final int year;
|
||||
private final Long countCommit;
|
||||
|
||||
public CommitTimeStatistic(Date date, Long countCommit) {
|
||||
this.date = date;
|
||||
public CommitTimeStatistic(int month, int year, Long countCommit) {
|
||||
this.month = month;
|
||||
this.year = year;
|
||||
this.countCommit = countCommit;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
public String getDate() {
|
||||
return String.format(DATE_TEMPLATE, month, year);
|
||||
}
|
||||
|
||||
public Long getCountCommit() {
|
||||
|
@ -29,13 +29,13 @@ public interface CommitRepository extends JpaRepository<Commit, Integer> {
|
||||
@Query("SELECT new ru.ulstu.extractor.model.CommitUrlStatistic(c.branch.repository.url, COUNT(DISTINCT c.hash)) FROM Commit c GROUP by c.branch.repository.url")
|
||||
List<CommitUrlStatistic> getCommitUrlStatistic();
|
||||
|
||||
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(cast(c.date as date), COUNT(DISTINCT c.hash)) FROM Commit c GROUP by cast(c.date as date) ORDER by cast(c.date as date)")
|
||||
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(extract(month FROM c.date) as month, extract(year FROM c.date) as year, COUNT(DISTINCT c.hash)) FROM Commit c GROUP by extract(month from c.date), extract(year from c.date) ORDER by extract(year from c.date), extract(month from c.date)")
|
||||
List<CommitTimeStatistic> getCommitTimeStatistic();
|
||||
|
||||
@Query("SELECT new ru.ulstu.extractor.model.CommitEntityStatistic(f.containsEntity, COUNT(DISTINCT c.hash)) FROM Commit c JOIN c.fileChanges f GROUP by f.containsEntity")
|
||||
List<CommitEntityStatistic> getCommitEntityStatistic();
|
||||
|
||||
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(cast(c.date as date), COUNT(DISTINCT c.hash)) FROM Commit c JOIN c.fileChanges f WHERE f.containsEntity = true GROUP by cast(c.date as date) ORDER by cast(c.date as date)")
|
||||
@Query("SELECT new ru.ulstu.extractor.model.CommitTimeStatistic(EXTRACT(MONTH FROM c.date), EXTRACT(YEAR FROM c.date), COUNT(DISTINCT c.hash)) FROM Commit c JOIN c.fileChanges f WHERE f.containsEntity = true GROUP by extract(month from c.date), extract(year from c.date) ORDER by extract(year from c.date), extract(month from c.date)")
|
||||
List<CommitTimeStatistic> getCommitTimeEntityStatistic();
|
||||
|
||||
void deleteByBranchIsNull();
|
||||
|
Loading…
Reference in New Issue
Block a user