Module Etl.Parsers

val (let*) : ('a, 'b) Stdlib.result -> ('a -> ('c, 'b) Stdlib.result) -> ('c, 'b) Stdlib.result
val show_status : Types.status -> string

Converts a status variant to its string representation.

  • parameter status

    Status variant to convert (Complete, Pending, or Cancelled)

  • returns

    String representation of the status

val show_origin : Types.origin -> string

Converts an origin variant to its string representation.

  • parameter origin

    Origin variant to convert (O or P)

  • returns

    String representation of the origin

val parse_int : string -> (int, [> `Invalid_int ]) Stdlib.result

Parses an integer from a string.

  • parameter raw_int

    String containing an integer

  • returns

    Parsed integer or an error

val parse_float : string -> (float, [> `Invalid_float ]) Stdlib.result

Parses a float from a string.

  • parameter raw_float

    String containing a float

  • returns

    Parsed float or an error

val parse_date : 'a -> ('a, 'b) Stdlib.result

Parses a date from a string.

  • parameter raw_date

    String containing a date

  • returns

    Parsed date

val parse_items : string -> (Types.item, [> `Invalid_float | `Invalid_int ]) Stdlib.result list

Parses items from a CSV string.

  • parameter csv_str

    CSV data as a string

  • returns

    List of parsed items

val parse_status : string -> (Types.status, [> `Unknown_status ]) Stdlib.result

Parses an order status from a string.

  • parameter status_str

    String representation of the status

  • returns

    Parsed status or an error

val parse_origin : string -> (Types.origin, [> `Unknown_origin ]) Stdlib.result

Parses an order origin from a string.

  • parameter origin_str

    String representation of the origin

  • returns

    Parsed origin or an error

val parse_id : string -> (int, [> `Invalid_id ]) Stdlib.result

Parses an ID from a string.

  • parameter raw_id

    String containing an ID

  • returns

    Parsed ID or an error

val parse_row : Csv.Row.t -> (Types.order, [> `Invalid_id | `Unknown_origin | `Unknown_status ]) Stdlib.result

Parses a row into an order record.

  • parameter row

    CSV row containing order data

  • returns

    Parsed order or an error

val parse_orders : string -> (Types.order, [> `Invalid_id | `Unknown_origin | `Unknown_status ]) Stdlib.result list

Parses orders from a CSV string.

  • parameter csv_str

    CSV data as a string

  • returns

    List of parsed orders

val unwrap_orders : ('a, 'b) Stdlib.result list -> 'a list

Filters out errors, returning only successful orders.

  • parameter order_results

    List of order results

  • returns

    List of successful orders

val unwrap_items : ('a, 'b) Stdlib.result list -> 'a list

Filters out errors, returning only successful items.

  • parameter item_results

    List of item results

  • returns

    List of successful items

val filter_orders : Types.user_input -> Types.order list -> Types.order list

Filters a list of orders based on user-specified status and origin criteria.

  • parameter user_input

    Record containing status_filter and origin_filter strings

  • parameter orders

    List of order records to filter

  • returns

    List of orders that match the specified filter criteria