Giter VIP home page Giter VIP logo

curioucity's People

Contributors

eiffelfly avatar

Watchers

 avatar

curioucity's Issues

feature request: support cursor based pagination

Context

Right now we only support page_size query body for backend to operate simple pagination. But it is not ideal.

  • If other user adds resource right before the user query our API, the data will miss or the order will change

Cursor based pagination is far better than limit and offset pagination.

feature-request: gRPC test issue

Context

The K6 need to know the proto file of the API to test the API. But when import the proto, the k6 can't find the imported proto from the original file.

chore: when use match pattern, we use result as variable name in the success path

Context

Currently, we use this match pattern in our backend

let discord_message =
        match db_third_party::discord::DiscordMessage::create(client, &payload).await {
            Ok(discord_message) => discord_message,
            Err(error) => {
                return Err((
                    StatusCode::INTERNAL_SERVER_ERROR,
                    format!(
                        "Something went wrong when create discord message: {}",
                        error
                    ),
                )
                    .into_response())
            }
        };

In order to reduce the overhead of coming up a variable name for Ok(), I purpose that we unify that as below

let discord_message =
        match db_third_party::discord::DiscordMessage::create(client, &payload).await {
            Ok(result) => result,
            Err(error) => {
                return Err((
                    StatusCode::INTERNAL_SERVER_ERROR,
                    format!(
                        "Something went wrong when create discord message: {}",
                        error
                    ),
                )
                    .into_response())
            }
        };

Instead of coming up a new name, we use result

Rest API endpoint proposal

Currently our REST API endpoint is

  • GET /resource_name/:resource_id: get resource
  • GET /resource_name: list resources
  • POST /resource_name: create resource
  • DELETE /resource_name with resource_id in body: delete resource

In order to make it more consistent, I would like to alter the design to

  • GET /resource_name/:resource_id: get resource
  • GET /resource_name: list resources
  • POST /resource_name/create: create resource
  • DELETE /resource_name/:resource_id with resource_id in body: delete resource

bug: use int32 type for page_size

Context

According to protobuf spec, int64 will be serialized as string in the form of JSON. Currently, int32 should suit our need enough.

feature: rethink how we handle JSON and markdown content

Currently, in our API we provide JSON object and markdown content in the DiscordThread object.

#[derive(Queryable, Serialize, Deserialize, Debug)]
pub struct DiscordThread {
    pub id: Uuid,
    pub kind: String,
    pub thread_id: String,
    #[edgedb(json)]
    pub full_messages_json: HashMap<String, String>,
    pub markdown_content: String,
    pub tags: Vec<Tag>,
    pub messages: Vec<DiscordMessage>,
    pub url: Url,
    pub created_timestamp_at_curioucity: String,
    pub created_timestamp_at_discord: String,
}

The upcoming questions are

  • When user delete discord message, how do we update the full_messages_json and markdown_content
  • We generate the markdown_content beforehand or when user query it
  • Do we need to provide these data at this moment?

test: enhance list endpoint e2e test

Context

Currently, we have this kind of test to test the list endpoint

check(http.request("GET", `${API_HOST}/tags`, undefined, { headers }), {
      "listTag - GET /tags - have two tags, should response 200": (r) =>
        r.status === 200,
      "listTag - GET /tags - have two tags, should response size=2": (r) =>
        r.json().size === "2",
    });

Sadly, it will have chance to get polluted by other testing, we may need to find better way to solve it.

feat: replace int64 timestamp with string

Context

Protobuf will serialize int64 to string in the form of JSON.

JSON cannot store 64-bit integers, instead only storing double-precision floats (which have a maximum integral precision of 52-bits)

We better store our timestamp in the form of string like GitHub API 2020-01-10T14:59:22Z

Reference

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.