> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powerdrill.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get job history in session

> Obtains the job history contained in the specified session.



## OpenAPI

````yaml get /v1/team/sessions/{sessionId}/history
openapi: 3.0.1
info:
  title: Team Open API
  description: ''
  version: 1.0.0
servers:
  - url: https://ai.data.cloud/api
    description: 体验环境
security: []
tags:
  - name: Session
  - name: Dataset
  - name: Data source
  - name: File
  - name: Job
paths:
  /v1/team/sessions/{sessionId}/history:
    get:
      tags:
        - Session
      summary: Get job history in session
      description: Obtains the job history contained in the specified session.
      parameters:
        - name: sessionId
          in: path
          description: The session ID.
          required: true
          schema:
            type: string
        - name: pageNumber
          in: query
          description: >-
            The number of pages to display. If not specified, the default value
            `1` will be used.
          required: false
          schema:
            type: integer
        - name: pageSize
          in: query
          description: >-
            The number of items on a single page. If not specified, the default
            value `10` will be used.
          required: false
          schema:
            type: integer
        - name: userId
          in: query
          description: >-
            Your user ID. 


            How to obtain your user ID: Sign in to Powerdrill Enterprise, click
            **Users** in the top navigation bar, and find your user ID in the
            list of users.
          required: true
          schema:
            type: string
        - name: x-pd-external-trace-id
          in: header
          description: The external trace ID. The length ranges from 0 to 128 characters.
          required: false
          example: ''
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    description: >-
                      Status code. **0** indicates that the operation is
                      successful. Otherwise, the operation fails. Possible error
                      codes include: 

                      - 100: Bad request. 

                      - 201: Request frequency limit.

                      - 9999: Internal error. 

                      - 100001: Invalid operation. 
                  data:
                    type: object
                    properties:
                      total:
                        type: integer
                        description: The total number of pages displayed.
                      pageNumber:
                        type: integer
                        description: The number of pages returned.
                      pageSize:
                        type: integer
                        description: The number of items displayed per page.
                      records:
                        type: array
                        items:
                          description: The information about each record.
                          type: object
                          properties:
                            question:
                              description: The user's question.
                              type: object
                              properties:
                                blocks:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - MESSAGE
                                          - CODE
                                          - TABLE
                                          - IMAGE
                                          - SOURCES
                                          - QUESTIONS
                                        description: The block type.
                                      content:
                                        type: string
                                        description: The block content.
                                    required:
                                      - type
                                      - content
                              required:
                                - blocks
                            answer:
                              description: The answer to the question.
                              type: object
                              properties:
                                blocks:
                                  type: array
                                  items:
                                    $ref: '#/components/schemas/BlockDTO'
                              required:
                                - blocks
                            jobId:
                              type: string
                              description: The job ID.
                          required:
                            - question
                            - answer
                            - jobId
                        description: The list of returned records.
                    required:
                      - total
                      - pageNumber
                      - pageSize
                      - records
                    description: The returned data object.
                required:
                  - data
                  - code
              examples:
                '1':
                  summary: Success example
                  value:
                    code: 0
                    data:
                      total: 0
                      pageNumber: 1
                      pageSize: 10
                      records:
                        - jobId: job-1dsfasddfasgddsaffds
                          question:
                            blocks:
                              - type: MESSAGE
                                content: >-
                                  Check for negative values across all sales
                                  columns
                          answer:
                            blocks:
                              - type: MESSAGE
                                content: >-
                                  - Check for negative values across all sales
                                  columns.

                                  - Filter the DataFrame to retain only rows
                                  with no negative sales values.
                                groupId: ba582fc9-bb36-4c5d-a8e8-d35bda6389cd
                                groupName: >-
                                  Identify the channels with negative sales
                                  values by examining each day's sales data.
                                  Filter out the rows where any sales value is
                                  negative.
                                stage: Analyze
                              - type: CODE
                                content: >-
                                  ```python


                                  import pandas as pd


                                  def invoke(input_0: pd.DataFrame) ->
                                  pd.DataFrame:
                                      '''
                                      input_0: pd.DataFrame  SalesByChannelByDay_Summary_Demo.Sheet1_0_table_1.csv
                                      '''
                                      # Identify columns that represent sales data (all except the first column)
                                      sales_columns = input_0.columns[1:]
                                      
                                      # Filter rows where any sales value is negative
                                      filtered_df = input_0[~(input_0[sales_columns] < 0).any(axis=1)]
                                      
                                      # Assign the result to the output variable
                                      output = filtered_df
                                      
                                      return output

                                  ```
                                groupId: ba582fc9-bb36-4c5d-a8e8-d35bda6389cd
                                groupName: >-
                                  Identify the channels with negative sales
                                  values by examining each day's sales data.
                                  Filter out the rows where any sales value is
                                  negative.
                                stage: Analyze
                              - type: TABLE
                                content: >-
                                  https://s3.amazonaws.com/powerdrilltest/tmp_datasource_cache/code_result/clvl4cad2001q01l1m522hxlu/baf7d6d1-fb81-4fdb-bcdd-32923d214c7b.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20241018T104617Z&X-Amz-SignedHeaders=host&X-Amz-Expires=599&X-Amz-Credential=AKIARLSQLXURHEIDN4OZ%2F20241018%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=9bcb5af552793f162e35f41d62fb9306cf90888924bfbdce81ea687265fddf83
                                groupId: ba582fc9-bb36-4c5d-a8e8-d35bda6389cd
                                groupName: >-
                                  Identify the channels with negative sales
                                  values by examining each day's sales data.
                                  Filter out the rows where any sales value is
                                  negative.
                                stage: Analyze
                              - type: MESSAGE
                                content: >-
                                  - Sum the sales across all days for each
                                  channel.

                                  - Create a new DataFrame with the channel
                                  names and their corresponding total sales.
                                groupId: 47183fd1-307b-4408-9986-e9238d952ec1
                                groupName: >-
                                  Calculate the overall sales trend for the
                                  identified channels with negative sales
                                  values. This involves summing up the sales
                                  across all days for each channel and analyzing
                                  the trend.
                                stage: Analyze
                              - type: CODE
                                content: >-
                                  ```python


                                  import pandas as pd


                                  def invoke(negative_sales_channels:
                                  pd.DataFrame) -> pd.DataFrame:
                                      '''
                                      negative_sales_channels: pd.DataFrame  negative_sales_channels.csv
                                      '''
                                      # Sum the sales across all days for each channel
                                      total_sales = negative_sales_channels.iloc[:, 1:].sum(axis=1)
                                      
                                      # Create a new DataFrame with the channel names and their corresponding total sales
                                      output = pd.DataFrame({
                                          'Channel': negative_sales_channels.iloc[:, 0],
                                          'Total Sales': total_sales
                                      })
                                      
                                      return output

                                  ```
                                groupId: 47183fd1-307b-4408-9986-e9238d952ec1
                                groupName: >-
                                  Calculate the overall sales trend for the
                                  identified channels with negative sales
                                  values. This involves summing up the sales
                                  across all days for each channel and analyzing
                                  the trend.
                                stage: Analyze
                              - type: TABLE
                                content: >-
                                  https://s3.amazonaws.com/powerdrilltest/tmp_datasource_cache/code_result/clvl4cad2001q01l1m522hxlu/10cffac2-8bf3-45f4-86e6-1ed8457329f2.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20241018T104617Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=AKIARLSQLXURHEIDN4OZ%2F20241018%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=c6f5b522d2ddceea730304b86a45d5f5165f05f9fda3c1d275d11e9022c1e7ac
                                groupId: 47183fd1-307b-4408-9986-e9238d952ec1
                                groupName: >-
                                  Calculate the overall sales trend for the
                                  identified channels with negative sales
                                  values. This involves summing up the sales
                                  across all days for each channel and analyzing
                                  the trend.
                                stage: Analyze
                              - type: MESSAGE
                                content: >-
                                  - Replace any negative sales values with zero
                                  in the data.

                                  - Sum the sales across all days for each
                                  channel.

                                  - Create a new data structure with the summed
                                  sales values.
                                groupId: 6b93c2b1-8908-4c2b-afb2-2a81f2d24739
                                groupName: >-
                                  Calculate the overall sales trend for the same
                                  channels but excluding the negative sales
                                  values. This involves setting negative values
                                  to zero or removing them and then summing up
                                  the sales across all days for each channel.
                                stage: Analyze
                              - type: CODE
                                content: >-
                                  ```python


                                  import pandas as pd


                                  def invoke(negative_sales_channels:
                                  pd.DataFrame) -> pd.DataFrame:
                                      '''
                                      negative_sales_channels: pd.DataFrame  negative_sales_channels.csv
                                      '''
                                      # Replace negative values with zero
                                      negative_sales_channels.iloc[:, 1:] = negative_sales_channels.iloc[:, 1:].clip(lower=0)
                                      
                                      # Sum the sales across all days for each channel
                                      sales_sum = negative_sales_channels.iloc[:, 1:].sum(axis=1)
                                      
                                      # Create a new DataFrame with the summed sales values
                                      output = pd.DataFrame({
                                          'Channel': negative_sales_channels.iloc[:, 0],
                                          'Total Sales': sales_sum
                                      })
                                      
                                      return output

                                  ```
                                groupId: 6b93c2b1-8908-4c2b-afb2-2a81f2d24739
                                groupName: >-
                                  Calculate the overall sales trend for the same
                                  channels but excluding the negative sales
                                  values. This involves setting negative values
                                  to zero or removing them and then summing up
                                  the sales across all days for each channel.
                                stage: Analyze
                              - type: TABLE
                                content: >-
                                  https://s3.amazonaws.com/powerdrilltest/tmp_datasource_cache/code_result/clvl4cad2001q01l1m522hxlu/f4c99616-dd7c-48b1-8a35-d3141d732c36.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20241018T104617Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=AKIARLSQLXURHEIDN4OZ%2F20241018%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=d21a8d939ab09547bc201754ba253ca6c0d1da5361752f2228237e3ff59be256
                                groupId: 6b93c2b1-8908-4c2b-afb2-2a81f2d24739
                                groupName: >-
                                  Calculate the overall sales trend for the same
                                  channels but excluding the negative sales
                                  values. This involves setting negative values
                                  to zero or removing them and then summing up
                                  the sales across all days for each channel.
                                stage: Analyze
                              - type: MESSAGE
                                content: >-
                                  - Merge the two datasets on the 'Channel'
                                  column to align sales data for comparison.

                                  - Calculate the difference in 'Total Sales'
                                  between the datasets for each channel.

                                  - Store the results, including channel name
                                  and calculated difference, in a new dataset.
                                groupId: 3488f538-f7fc-4c0e-a265-b66e3a38d41e
                                groupName: >-
                                  Compare the sales trends with and without
                                  negative sales values to determine the impact
                                  of negative sales on the overall sales trend
                                  for the affected channels.
                                stage: Analyze
                              - type: CODE
                                content: >-
                                  ```python


                                  import pandas as pd


                                  def invoke(sales_trend_with_negatives:
                                  pd.DataFrame, sales_trend_without_negatives:
                                  pd.DataFrame) -> pd.DataFrame:
                                      # Merge the two DataFrames on the 'Channel' column
                                      merged_df = pd.merge(sales_trend_with_negatives, sales_trend_without_negatives, on='Channel', suffixes=('_with_negatives', '_without_negatives'))
                                      
                                      # Calculate the difference in 'Total Sales' between the two DataFrames
                                      merged_df['Sales Difference'] = merged_df['Total Sales_without_negatives'] - merged_df['Total Sales_with_negatives']
                                      
                                      # Create a new DataFrame to store the results
                                      output = merged_df[['Channel', 'Sales Difference']]
                                      
                                      return output

                                  ```
                                groupId: 3488f538-f7fc-4c0e-a265-b66e3a38d41e
                                groupName: >-
                                  Compare the sales trends with and without
                                  negative sales values to determine the impact
                                  of negative sales on the overall sales trend
                                  for the affected channels.
                                stage: Analyze
                              - type: TABLE
                                content: >-
                                  https://s3.amazonaws.com/powerdrilltest/tmp_datasource_cache/code_result/clvl4cad2001q01l1m522hxlu/aaf4f2f7-e2db-4f2e-98ae-0bdd18f42333.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20241018T104617Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=AKIARLSQLXURHEIDN4OZ%2F20241018%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=19fcfe97c70bf40292b920ecbf0299c101e1de11e49b54fb8f62934b6e874f52
                                groupId: 3488f538-f7fc-4c0e-a265-b66e3a38d41e
                                groupName: >-
                                  Compare the sales trends with and without
                                  negative sales values to determine the impact
                                  of negative sales on the overall sales trend
                                  for the affected channels.
                                stage: Analyze
                              - type: MESSAGE
                                content: >+


                                  `Analyzing Conclusions` 


                                  ### The impact of negative sales values on
                                  overall sales trends


                                  #### Sales variance analysis

                                groupId: fd1a62e6-48cf-4ac1-8bac-025665444710
                                groupName: Conclusions
                                stage: Respond
                              - type: TABLE
                                content: >-
                                  https://s3.amazonaws.com/powerdrilltest/tmp_datasource_cache/code_result/clvl4cad2001q01l1m522hxlu/aaf4f2f7-e2db-4f2e-98ae-0bdd18f42333.csv?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20241018T104617Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=AKIARLSQLXURHEIDN4OZ%2F20241018%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=19fcfe97c70bf40292b920ecbf0299c101e1de11e49b54fb8f62934b6e874f52
                                groupId: fd1a62e6-48cf-4ac1-8bac-025665444710
                                groupName: Conclusions
                                stage: Respond
                              - type: MESSAGE
                                content: >-


                                  - **Sales variance**：In all channels
                                  (including EC, JD, Tmall, WeChat, retail,
                                  corporate stores, outlets, and total), the
                                  sales difference is 0.0. This indicates that
                                  regardless of the presence of negative sales
                                  values, the sales trend has not changed.


                                  #### Conclusion and Insights

                                  - **The impact of negative sales
                                  values**：Based on the provided data, negative
                                  sales values have no impact on the overall
                                  sales trend of the affected channels, as the
                                  sales variance for all channels is 0.0.

                                  - **Data consistency**：The sales discrepancies
                                  across all channels are consistent, indicating
                                  that there are no anomalies or deviations
                                  caused by negative sales values during data
                                  processing or analysis.
                                groupId: fd1a62e6-48cf-4ac1-8bac-025665444710
                                groupName: Conclusions
                                stage: Respond
                              - type: SOURCES
                                content:
                                  - source: SalesByChannelByDay_Summary_Demo.xlsx
                                    datasourceId: cm2ej4wmo000001fcdkwbdrml
                                    datasetId: cm2ej4vx900hp01l1o378zr9o
                                    fileType: xlsx
                                    externalId: ''
                                groupId: ''
                                groupName: ''
                                stage: Respond
                              - type: QUESTIONS
                                content:
                                  - >-
                                    Analyze the specific channels with negative
                                    sales values on different dates and discuss
                                    whether the sales strategies of these
                                    channels might lead to negative values.
                                  - >-
                                    Study the long-term impact of negative sales
                                    values on overall sales trends and assess
                                    whether adjustments to data analysis methods
                                    are needed to more accurately reflect the
                                    actual situation.
                                  - >-
                                    Investigate the source of negative sales
                                    values, whether they are related to returns,
                                    discounts, or other factors, and propose
                                    possible solutions to reduce the occurrence
                                    of negative values.
                                groupId: '-1'
                                stage: Respond
          headers:
            x-pd-trace-id:
              example: ''
              required: true
              description: The trace ID of Powerdrill.
              schema:
                type: string
      deprecated: false
      security:
        - apikey-header-x-pd-api-key: []
components:
  schemas:
    BlockDTO:
      type: object
      properties:
        type:
          type: string
          enum:
            - MESSAGE
            - CODE
            - TABLE
            - IMAGE
            - SOURCES
            - QUESTIONS
          description: The block type.
        content:
          type: string
          description: The block content.
        groupId:
          type: string
          description: The ID of the group containing the block.
        groupName:
          type: string
          description: The name of the group containing the block.
        stage:
          type: string
          enum:
            - Analyze
            - Respond
          description: The stage of the block.
      required:
        - type
        - content
        - groupId
        - groupName
        - stage
  securitySchemes:
    apikey-header-x-pd-api-key:
      type: apiKey
      in: header
      name: x-pd-api-key

````