-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
amvanbaren
committed
Jan 17, 2025
1 parent
37a929d
commit 4430c80
Showing
23 changed files
with
952 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
server/src/main/java/org/eclipse/openvsx/entities/PublisherStatistics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** ****************************************************************************** | ||
* Copyright (c) 2024 Precies. Software OU and others | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* ****************************************************************************** */ | ||
package org.eclipse.openvsx.entities; | ||
|
||
import jakarta.persistence.*; | ||
import org.eclipse.openvsx.json.PublisherStatisticsJson; | ||
|
||
import java.util.*; | ||
|
||
@Entity | ||
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "year", "month"})}) | ||
public class PublisherStatistics { | ||
|
||
@Id | ||
@GeneratedValue(generator = "publisherStatisticsSeq") | ||
@SequenceGenerator(name = "publisherStatisticsSeq", sequenceName = "publisher_statistics_seq") | ||
private long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_data") | ||
private UserData user; | ||
|
||
private int year; | ||
|
||
private int month; | ||
|
||
@ElementCollection(fetch = FetchType.EAGER) | ||
@MapKeyColumn(name = "extension_identifier") | ||
@Column(name = "downloads") | ||
private Map<String, Long> extensionDownloads; | ||
|
||
@ElementCollection(fetch = FetchType.EAGER) | ||
@MapKeyColumn(name = "extension_identifier") | ||
@Column(name = "downloads") | ||
private Map<String, Long> extensionTotalDownloads; | ||
|
||
public PublisherStatisticsJson toJson() { | ||
var json = new PublisherStatisticsJson(); | ||
json.setYear(year); | ||
json.setMonth(month); | ||
json.setExtensionDownloads(extensionDownloads); | ||
json.setExtensionTotalDownloads(extensionTotalDownloads); | ||
return json; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public UserData getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(UserData user) { | ||
this.user = user; | ||
} | ||
|
||
public int getYear() { | ||
return year; | ||
} | ||
|
||
public void setYear(int year) { | ||
this.year = year; | ||
} | ||
|
||
public int getMonth() { | ||
return month; | ||
} | ||
|
||
public void setMonth(int month) { | ||
this.month = month; | ||
} | ||
|
||
public Map<String, Long> getExtensionDownloads() { | ||
return extensionDownloads; | ||
} | ||
|
||
public void setExtensionDownloads(Map<String, Long> extensionDownloads) { | ||
this.extensionDownloads = extensionDownloads; | ||
} | ||
|
||
public Map<String, Long> getExtensionTotalDownloads() { | ||
return extensionTotalDownloads; | ||
} | ||
|
||
public void setExtensionTotalDownloads(Map<String, Long> extensionTotalDownloads) { | ||
this.extensionTotalDownloads = extensionTotalDownloads; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
server/src/main/java/org/eclipse/openvsx/json/PublisherStatisticsJson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** ****************************************************************************** | ||
* Copyright (c) 2024 Precies. Software OU and others | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* ****************************************************************************** */ | ||
package org.eclipse.openvsx.json; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import java.util.Map; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class PublisherStatisticsJson extends ResultJson { | ||
|
||
public static PublisherStatisticsJson error(String message) { | ||
var result = new PublisherStatisticsJson(); | ||
result.setError(message); | ||
return result; | ||
} | ||
|
||
private int year; | ||
|
||
private int month; | ||
|
||
private Map<String, Long> extensionDownloads; | ||
|
||
private Map<String, Long> extensionTotalDownloads; | ||
|
||
public int getYear() { | ||
return year; | ||
} | ||
|
||
public void setYear(int year) { | ||
this.year = year; | ||
} | ||
|
||
public int getMonth() { | ||
return month; | ||
} | ||
|
||
public void setMonth(int month) { | ||
this.month = month; | ||
} | ||
|
||
public Map<String, Long> getExtensionDownloads() { | ||
return extensionDownloads; | ||
} | ||
|
||
public void setExtensionDownloads(Map<String, Long> extensionDownlaods) { | ||
this.extensionDownloads = extensionDownlaods; | ||
} | ||
|
||
public Map<String, Long> getExtensionTotalDownloads() { | ||
return extensionTotalDownloads; | ||
} | ||
|
||
public void setExtensionTotalDownloads(Map<String, Long> extensionTotalDownlaods) { | ||
this.extensionTotalDownloads = extensionTotalDownlaods; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
server/src/main/java/org/eclipse/openvsx/repositories/PublisherStatisticsRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** ****************************************************************************** | ||
* Copyright (c) 2024 Precies. Software OU and others | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* ****************************************************************************** */ | ||
package org.eclipse.openvsx.repositories; | ||
|
||
import org.eclipse.openvsx.entities.PublisherStatistics; | ||
import org.eclipse.openvsx.entities.UserData; | ||
import org.springframework.data.repository.Repository; | ||
import org.springframework.data.util.Streamable; | ||
|
||
public interface PublisherStatisticsRepository extends Repository<PublisherStatistics, Long> { | ||
|
||
PublisherStatistics findByYearAndMonthAndUser(int year, int month, UserData user); | ||
|
||
Streamable<PublisherStatistics> findByUser(UserData user); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.