images: update proto
This commit is contained in:
parent
dcbcbddcea
commit
39c0ef1bd9
8
Makefile
8
Makefile
|
@ -16,11 +16,11 @@ run-web: generate-web
|
||||||
cd web && npm run dev
|
cd web && npm run dev
|
||||||
|
|
||||||
generate-go: migrate
|
generate-go: migrate
|
||||||
rm -rf go/gen/*
|
@rm -rf go/gen/*
|
||||||
ogen -target go/gen/reddit -package reddit -clean schemas/openapi/reddit.yaml
|
ogen -target go/gen/reddit -package reddit -clean schemas/openapi/reddit.yaml 2>&1 | grep -v INFO
|
||||||
jet -source=sqlite -dsn="./go/data.db" -path="./go/gen/jet"
|
jet -source=sqlite -dsn="./go/data.db" -path="./go/gen/jet" | grep -v "Unsupported sql column"
|
||||||
(cd ./schemas/proto && buf generate --template buf.gen.go.yaml .)
|
(cd ./schemas/proto && buf generate --template buf.gen.go.yaml .)
|
||||||
(cd go/gen && bobgen-sqlite --config ../bobgen.yaml)
|
(cd go/gen && bobgen-sqlite --config ../bobgen.yaml 2>&1 | grep -v bytes | grep -v SKIPPED)
|
||||||
(cd go && goverter gen -g 'output:file ../gen/converter/converter.go' -g 'output:package github.com/tigorlazuardi/bluemage/go/gen/converter' ./converts)
|
(cd go && goverter gen -g 'output:file ../gen/converter/converter.go' -g 'output:package github.com/tigorlazuardi/bluemage/go/gen/converter' ./converts)
|
||||||
|
|
||||||
generate-web:
|
generate-web:
|
||||||
|
|
35
go/api/images_recently_added.go
Normal file
35
go/api/images_recently_added.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/tigorlazuardi/bluemage/go/gen/jet/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RecentlyAddedImagesRequest struct {
|
||||||
|
Subreddits []string
|
||||||
|
Devices []string
|
||||||
|
Limit int64
|
||||||
|
After int64
|
||||||
|
Before int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type RecentlyAddedImagesResponse struct {
|
||||||
|
Groups []RecentlyAddedImagesSubredditGroup
|
||||||
|
After *int64
|
||||||
|
Before *int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type RecentlyAddedImagesSubredditGroup struct {
|
||||||
|
Name string
|
||||||
|
Devices []RecentlyAddedImagesDeviceGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
type RecentlyAddedImagesDeviceGroup struct {
|
||||||
|
Slug string
|
||||||
|
Name string
|
||||||
|
Images []model.Images
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *API) RecentlyAddedImages(ctx context.Context, request RecentlyAddedImagesRequest) {
|
||||||
|
}
|
56
schemas/proto/images/v1/recently_added.proto
Normal file
56
schemas/proto/images/v1/recently_added.proto
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package images.v1;
|
||||||
|
|
||||||
|
import "buf/validate/validate.proto";
|
||||||
|
import "images/v1/types.proto";
|
||||||
|
|
||||||
|
message RecentlyAddedImagesRequest {
|
||||||
|
option (buf.validate.message).cel = {
|
||||||
|
id: "RecentlyAddedImagesRequest.after_cannot_exist_with_before"
|
||||||
|
message: "after and before cannot be set at the same time"
|
||||||
|
expression: "this.after > 0 && this.before > 0"
|
||||||
|
};
|
||||||
|
// subreddits filter the images to be fetched belonging to the given subreddits.
|
||||||
|
//
|
||||||
|
// If empty, images from all subreddits will be fetched.
|
||||||
|
repeated string subreddits = 1;
|
||||||
|
// devices is a filter the images to be fetched belonging to the given devices slug.
|
||||||
|
//
|
||||||
|
// If empty, images from all devices will be fetched.
|
||||||
|
repeated string devices = 2;
|
||||||
|
// limit limits the number of images to be fetched.
|
||||||
|
//
|
||||||
|
// if 0 (or not set), the default limit is 100.
|
||||||
|
//
|
||||||
|
// if set, the maximum limit is clamped to 300.
|
||||||
|
int64 limit = 3 [(buf.validate.field).int64.gte = 0];
|
||||||
|
// after lists the image after the given timestamp.
|
||||||
|
//
|
||||||
|
// using after will return images that are created after the given timestamp.
|
||||||
|
//
|
||||||
|
// cannot be set (value > 0) with before (value > 0).
|
||||||
|
int64 after = 4;
|
||||||
|
// before lists the image before the given timestamp.
|
||||||
|
//
|
||||||
|
// using before will return images that are created before the given timestamp.
|
||||||
|
//
|
||||||
|
// cannot be set (value > 0) with after (value > 0).
|
||||||
|
int64 before = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RecentlyAddedImagesResponse {
|
||||||
|
// groups are images grouped by devices.
|
||||||
|
//
|
||||||
|
// devices are sorted alphabetically by it's NAME not slug.
|
||||||
|
repeated GroupedBySubredditDevices groups = 1;
|
||||||
|
// after is a unix epoch timestamp given to the client to be used as after in the next request.
|
||||||
|
//
|
||||||
|
// Given if the request has after value set and there are more images to be fetched.
|
||||||
|
optional int64 after = 2;
|
||||||
|
|
||||||
|
// before is a unix epoch timestamp given to the client to be used as before in the next request.
|
||||||
|
//
|
||||||
|
// Given if the request has before value set and there are more images to be fetched.
|
||||||
|
optional int64 before = 3;
|
||||||
|
}
|
Loading…
Reference in a new issue