Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Create resources for cricket: format, state and event #26

Open
majorbruteforce opened this issue Dec 30, 2024 · 3 comments
Open
Assignees

Comments

@majorbruteforce
Copy link
Member

  • Create independent entities CricketFormats, CricketStates and CricketEvents under base path /cricket
  • The following additional endpoints are expected :
    • GET /:matchId/state : To fetch the latest match state
    • GET /:matchId/event?id=previousEventId : To fetch the most recent event next to the passed event (get most recent if nothing is passed)
    • GET /:matchId/event-series?id=previousEventId : To fetch all the events for the match sorted in descending order of time after the event with id previousEventId. (get all if nothing is passed)
    • POST /:matchId/event : To post a new event.
    • PATCH /event/:eventId : To patch a created event
    • DELETE /event/:eventId : To delete a created event

NOTE: Comment the schema for the three entities in the same thread.

@abir499-ban
Copy link
Contributor

Mongoose Schema for Cricket State

@majorbruteforce Please verify this Mongoose Schema for Cricket State

@Prop({
    type: Types.ObjectId,
    required: true,
    index: true,
    ref: Matches.name,
    set: EnsureObjectId
  })
  match : Types.ObjectId
  @Prop({
    type: Object,
    required: true,
  })
  innings: {
    first: {
      battingTeam: string;
      totalRuns: number;
      over: number;
      wicketsFallen: number;
      Batting: {
        striker: {
          name: string;
          runs: number;
          outReason: string | null;
        };
        nonStriker: {
          name: string;
          runs: number;
          outReason: string | null;
        };
        order: Array<{
          name: string;
          runs: number;
          status: string;
          profileLink: string;
          outReason: string[];
        }>;
      };
      Bowling: {
        freeHit: boolean;
        bowler: {
          name: string;
          overs: number;
          runsConceded: number;
          wickets: number;
        };
        currentOver: Array<{
          ball: number;
          runs: number;
          illegal: string | null;
        }>;
        order: Array<{
          name: string;
          overs: number;
          runsConceded: number;
          wickets: number;
          profileLink: string;
        }>;
        extras: {
          noBalls: number;
          wides: number;
          byes: number;
          legByes: number;
        };
      };
      inningsStatus: string;
      target: number | null;
    };
    second: {
      battingTeam: string;
      totalRuns: number;
      over: number;
      wicketsFallen: number;
      Batting: {
        striker: string | null;
        nonStriker: string | null;
        order: Array<{
          name: string;
          runs: number;
          status: string;
          profileLink: string;
          outReason: string[];
        }>;
      };
      Bowling: {
        bowler: string | null;
        currentOver: any[];
        extras: {
          noBalls: number;
          wides: number;
          byes: number;
          legByes: number;
        };
      };
      inningsStatus: string;
      target: number;
    };
  };

  @Prop({ trim: true })
  interrupted: string;

  @Prop({ trim: true })
  teamACaptain: string;

  @Prop({ trim: true })
  teamBCaptain: string;

  @Prop({ trim: true })
  teamAWicketKeeper: string;

  @Prop({ trim: true })
  teamBWicketKeeper: string;

  @Prop({
    type: [String],
  })
  umpires: string[];

  @Prop({ trim: true })
  matchStatus: string;

  @Prop({
    type: [String],
  })
  matchoutcome: string[];

@abir499-ban
Copy link
Contributor

Mongoose Schema for Cricket Event

@majorbruteforce please verify this Mongoose Schema for Cricket event

      @Prop({
        type: `Types.ObjectId,`
        required: true,
        index: true,
        ref: Matches.name,
        set: EnsureObjectId
       })
    match: Types.ObjectId

    @Prop({
        type: String,
        required: true,
    })
    type: string;

    @Prop({
        type: Object,
        required: true
    })
    details: {
        runs?: number | null;
        playerOut?: string | null;
        outReason?: any[];
        wickets?: number | null;
        scoringType?: number | null;
        illegal?: string | null;
        penalty?: number | null
    }

@abir499-ban
Copy link
Contributor

Mongoose Schema for Cricket Format

@majorbruteforce please verify the Mongoose Schema for Cricket Format

@Prop({
        required: true,
        index: true,
        trim: true
    })
    sport: string;

    @Prop()
    totalOvers: number

    @Prop()
    powerplayOvers: number

    @Prop()
    legalDeliveriesPerOver: number

    @Prop({
        type: Object
    })
    penaltyActions: PenaltyActions

    @Prop({
        type: Object
    })
    extraActions: ExtraActions

Types for the Cricket Format Schema

enum PenaltyType  {
    no_ball = "no_ball",
    wide  = "wide",
    field_obstruction  = "field_obstruction",
    over_rate_exceeded = "over_rate_exceeded",

}

declare type PenaltyActions = {
    illegal : PenaltyType,
    freeHit : boolean,
    penalty : number
}

enum ExtraActionsType{
    byes = "byes",
    leg_byes = "leg_byes",
    feilding_error = "feilding_error",
}

declare type ExtraActions = {
    type : ExtraActionsType,
    penalty : number,
    description : string
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants