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

Migrate to a better GraphQL query for usage #362

Open
ryanw-mobile opened this issue Nov 20, 2024 · 1 comment
Open

Migrate to a better GraphQL query for usage #362

ryanw-mobile opened this issue Nov 20, 2024 · 1 comment
Assignees
Labels
feature A new feature for the user, not a new feature for a build script.

Comments

@ryanw-mobile
Copy link
Owner

From official Octopus GraphQL usage:

query getMeasurements($accountNumber: String!, $first: Int!, $utilityFilters: [UtilityFiltersInput!], $startOn: Date, $endOn: Date, $startAt: DateTime, $endAt: DateTime, $timezone: String, $cursor: String) {
  account(accountNumber: $accountNumber) {
    properties {
      id
      measurements(
        first: $first
        utilityFilters: $utilityFilters
        startOn: $startOn
        endOn: $endOn
        startAt: $startAt
        endAt: $endAt
        timezone: $timezone
        after: $cursor
      ) {
        edges {
          node {
            value
            unit
            ... on IntervalMeasurementType {
              startAt
              endAt
              __typename
            }
            metaData {
              statistics {
                costInclTax {
                  costCurrency
                  estimatedAmount
                  __typename
                }
                value
                description
                label
                type
                __typename
              }
              __typename
            }
            __typename
          }
          __typename
        }
        pageInfo {
          hasNextPage
          hasPreviousPage
          startCursor
          endCursor
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
}

Variables:

accountNumber: "A-******"
endAt: "2024-10-19T22:59:59.999Z"
first: 60
startAt: "2024-10-18T23:00:00.000Z"
timezone: "Europe/London"
utilityFilters: 
{
electricityFilters: {
deviceId: "******"
marketSupplyPointId: "*****"
readingDirection: "CONSUMPTION"
readingFrequencyType: "HOUR_INTERVAL"
}

The returned value contains the parsed standing charge and consumption cost,
so we don't have to fetch and parse the raw readings and lookup tariffs.

@ryanw-mobile ryanw-mobile added the feature A new feature for the user, not a new feature for a build script. label Nov 20, 2024
@ryanw-mobile ryanw-mobile self-assigned this Nov 20, 2024
@ryanw-mobile
Copy link
Owner Author

Progress and to-dos on 9 Feb 2024:

  • Migrated to GraphQL and matched the domain model structure - that means the data presented should remain the same.
  • UserProfile is passed from Usage Screen to use case as preferences do not currently store device Id for the selected meter.
  • local cache currently keep indexing data using meter serial, but we have to migrate to use device id and retire meter serial. (so DB schema has to be upgraded)
  • Domain model has to be modified to add data fields to keep the cost for that consumption - so that we can then remove the cost lookup in viewmodel/usecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature for the user, not a new feature for a build script.
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant