-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/0.39.0' into main
- Loading branch information
Showing
138 changed files
with
3,586 additions
and
3,452 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,7 @@ package-lock.json | |
|
||
# Testing | ||
cypress | ||
|
||
# Airy config files | ||
airy.yaml | ||
cli.yaml |
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.38.1 | ||
0.39.0 |
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
36 changes: 36 additions & 0 deletions
36
backend/api/admin/src/main/java/co/airy/core/api/admin/TimestampExtractor.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,36 @@ | ||
package co.airy.core.api.admin; | ||
|
||
import co.airy.avro.ops.HttpLog; | ||
import co.airy.core.api.admin.dto.LogWithTimestamp; | ||
import org.apache.kafka.streams.KeyValue; | ||
import org.apache.kafka.streams.kstream.Transformer; | ||
import org.apache.kafka.streams.kstream.TransformerSupplier; | ||
import org.apache.kafka.streams.processor.ProcessorContext; | ||
|
||
public class TimestampExtractor { | ||
public static TransformerSupplier<String, HttpLog, KeyValue<String, LogWithTimestamp>> timestampExtractor() { | ||
return new TransformerSupplier<>() { | ||
@Override | ||
public Transformer<String, HttpLog, KeyValue<String, LogWithTimestamp>> get() { | ||
return new Transformer<>() { | ||
|
||
private ProcessorContext context; | ||
|
||
@Override | ||
public void init(ProcessorContext processorContext) { | ||
this.context = processorContext; | ||
} | ||
|
||
@Override | ||
public KeyValue<String, LogWithTimestamp> transform(String logId, HttpLog log) { | ||
return KeyValue.pair(logId, new LogWithTimestamp(context.timestamp(), log)); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
backend/api/admin/src/main/java/co/airy/core/api/admin/UsersController.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,47 @@ | ||
package co.airy.core.api.admin; | ||
|
||
import co.airy.avro.communication.User; | ||
import co.airy.core.api.admin.payload.ListUsersResponsePayload; | ||
import co.airy.core.api.admin.payload.PaginationData; | ||
import co.airy.core.api.admin.payload.UserResponsePayload; | ||
import co.airy.core.api.admin.payload.UsersListRequestPayload; | ||
import co.airy.pagination.Page; | ||
import co.airy.pagination.Paginator; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.validation.Valid; | ||
import java.util.List; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
@RestController | ||
public class UsersController { | ||
private final Stores stores; | ||
|
||
public UsersController(Stores stores) { | ||
this.stores = stores; | ||
} | ||
|
||
@PostMapping("/users.list") | ||
public ResponseEntity<?> list(@RequestBody(required = false) @Valid UsersListRequestPayload payload) { | ||
payload = payload == null ? new UsersListRequestPayload() : payload; | ||
|
||
final List<User> users = stores.getUsers(); | ||
Paginator<User> paginator = new Paginator<>(users, User::getId) | ||
.perPage(payload.getPageSize()).from(payload.getCursor()); | ||
|
||
Page<User> page = paginator.page(); | ||
|
||
return ResponseEntity.ok(ListUsersResponsePayload.builder() | ||
.data(page.getData().stream().map(UserResponsePayload::fromUser).collect(toList())) | ||
.paginationData(PaginationData.builder() | ||
.nextCursor(page.getNextCursor()) | ||
.previousCursor(page.getPreviousCursor()) | ||
.total(users.size()) | ||
.build()).build()); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
backend/api/admin/src/main/java/co/airy/core/api/admin/dto/LogWithTimestamp.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,16 @@ | ||
package co.airy.core.api.admin.dto; | ||
|
||
import co.airy.avro.ops.HttpLog; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class LogWithTimestamp implements Serializable { | ||
private long timestamp; | ||
private HttpLog log; | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/api/admin/src/main/java/co/airy/core/api/admin/payload/ListUsersResponsePayload.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,17 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ListUsersResponsePayload { | ||
private List<UserResponsePayload> data; | ||
private PaginationData paginationData; | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/api/admin/src/main/java/co/airy/core/api/admin/payload/PaginationData.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,16 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PaginationData { | ||
private String previousCursor; | ||
private String nextCursor; | ||
private long total; | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/api/admin/src/main/java/co/airy/core/api/admin/payload/UserResponsePayload.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,27 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import co.airy.avro.communication.User; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import static co.airy.date.format.DateFormat.isoFromMillis; | ||
|
||
@Data | ||
@Builder | ||
public class UserResponsePayload { | ||
private String id; | ||
private String name; | ||
private String avatarUrl; | ||
private String firstSeenAt; | ||
private String lastSeenAt; | ||
|
||
public static UserResponsePayload fromUser(User user) { | ||
return UserResponsePayload.builder() | ||
.id(user.getId()) | ||
.name(user.getName()) | ||
.avatarUrl(user.getAvatarUrl()) | ||
.firstSeenAt(isoFromMillis(user.getFirstSeenAt())) | ||
.lastSeenAt(isoFromMillis(user.getLastSeenAt())) | ||
.build(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
backend/api/admin/src/main/java/co/airy/core/api/admin/payload/UsersListRequestPayload.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,14 @@ | ||
package co.airy.core.api.admin.payload; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class UsersListRequestPayload { | ||
private String cursor; | ||
private Integer pageSize = 20; | ||
} |
Oops, something went wrong.