Skip to content

Commit 5000d40

Browse files
committed
feat: 0.2.0
Add 1 year ago
1 parent 8bbec55 commit 5000d40

File tree

8 files changed

+18
-8
lines changed

8 files changed

+18
-8
lines changed

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ RUN mvn -DskipTests package
1414

1515
FROM amazoncorretto:17-alpine3.17
1616

17+
LABEL org.opencontainers.image.source = "https://github.com/chuuuevi/git-stat"
18+
1719
MAINTAINER "chuuuevi <[email protected]>"
1820

1921
ARG TIME_ZONE=Asia/Shanghai

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ docker pull ghcr.io/chuuuevi/git-stat
1717
```
1818

1919
```bash
20-
docker run --rm -it \
20+
docker run --rm -it -d \
2121
-p 8080:8080 \
22-
-v $YOUR_REPO_DIR:/repo \
23-
ghcr.io/chuuuevi/git-stat
22+
-v ./:/repo \
23+
ghcr.io/chuuuevi/git-stat:0.1.0
2424
```

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>io.github.chuuuevi</groupId>
1212
<artifactId>git-stat</artifactId>
13-
<version>0.1.0</version>
13+
<version>0.2.0</version>
1414
<name>git-stat</name>
1515
<description>git-stat</description>
1616
<properties>

src/main/java/io/github/chuuuevi/gitstat/modules/action/GitController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public String index() {
3131

3232
@RequestMapping("/git/stat")
3333
@ResponseBody
34-
public Result<List<StatData>> statGit(@Valid @RequestParam(value = "method", required = true) @Min(0) @Max(3) Integer method,
34+
public Result<List<StatData>> statGit(@Valid @RequestParam(value = "method", required = true) @Min(0) @Max(4) Integer method,
3535
@RequestParam(value = "startDate", required = false) String startDate,
3636
@RequestParam(value = "endDate", required = false) String endDate,
3737
@RequestParam(value = "name", required = false) String name,

src/main/java/io/github/chuuuevi/gitstat/modules/stat/constant/Constants.java

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface GitConstants {
1414
int STAT_METHOD_DAY = 1;
1515
int STAT_METHOD_WEEK = 2;
1616
int STAT_METHOD_MONTH = 3;
17+
int STAT_METHOD_YEAR = 4;
1718
int STAT_METHOD_CUSTOM = 0;
1819
}
1920
}

src/main/java/io/github/chuuuevi/gitstat/modules/stat/service/GitStatService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
* Created by Jacky on 2015/7/14.
99
*/
1010
public interface GitStatService {
11-
List<StatData> stat(Integer method, String startDate,
11+
List<StatData> stat(int method, String startDate,
1212
String endDate, String author, String gitRoot) throws Exception;
1313
}

src/main/java/io/github/chuuuevi/gitstat/modules/stat/service/impl/GitStatServiceImpl.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class GitStatServiceImpl implements GitStatService {
3030
private final Pattern pat = Pattern.compile("(\\d+)\\s(\\d+)\\s");
3131

3232
@Override
33-
public List<StatData> stat(Integer method, String startDate,
33+
public List<StatData> stat(int method, String startDate,
3434
String endDate, String author, String gitRoot) throws Exception {
3535

3636
Stack<String> result = multiCmdExec(method, startDate, endDate, author, gitRoot);
@@ -124,12 +124,17 @@ private StatParam calcDays(int method, String startDate, String endDate) throws
124124
days = 7;
125125
}
126126
case Constants.GitConstants.STAT_METHOD_MONTH -> {
127-
Date today = new Date();
128127
lastTime = cur.getTime();
129128
cur.add(Calendar.MONTH, -1);
130129
startTime = cur.getTime();
131130
days = (lastTime.getTime() - startTime.getTime()) / Constants.StaticParam.DAY_MILLIONSECOND;
132131
}
132+
case Constants.GitConstants.STAT_METHOD_YEAR -> {
133+
lastTime = cur.getTime();
134+
cur.add(Calendar.YEAR, -1);
135+
startTime = cur.getTime();
136+
days = (lastTime.getTime() - startTime.getTime()) / Constants.StaticParam.DAY_MILLIONSECOND;
137+
}
133138
default -> {
134139
}
135140
}
@@ -167,6 +172,7 @@ private Stack<String> multiCmdExec(int method,
167172
case Constants.GitConstants.STAT_METHOD_DAY -> since = "1.day.ago";
168173
case Constants.GitConstants.STAT_METHOD_WEEK -> since = "1.week.ago";
169174
case Constants.GitConstants.STAT_METHOD_MONTH -> since = "1.month.ago";
175+
case Constants.GitConstants.STAT_METHOD_YEAR -> since = "1.year.ago";
170176
default -> {
171177
}
172178
}

src/main/resources/static/stat/gitstat.html

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<option value="1">Today</option>
2424
<option value="2">This Week</option>
2525
<option value="3">This Month</option>
26+
<option value="4">This Year</option>
2627
<option value="0">Customer</option>
2728
</select>
2829
<input id="startDate" type="date" disabled="false">

0 commit comments

Comments
 (0)