Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 16, 2025

This PR adds a timezone field to the sensor location data table to enable proper timezone context for sensor data across different geographical locations.

Changes Made

Database Layer

  • Added timezone field as Column(String(50)) to the Location model in app/database/models.py
  • Created Alembic migration e3f8f2a9b5c1_add_timezone_to_locations.py to add the timezone column to the api_locations table
  • Field is optional (nullable) to maintain backward compatibility with existing data

GraphQL API Layer

  • Added timezone: Optional[str] field to the Location GraphQL type
  • Updated CreateLocationInput and UpdateLocationInput to accept timezone parameter
  • Modified Location.from_model() method to include timezone field mapping
  • Updated create_location and update_location resolvers to handle timezone field

Usage

The timezone field supports standard IANA timezone identifiers and can be used in GraphQL operations:

# Query locations with timezone information
query {
  locations {
    id
    name
    city
    country
    timezone
  }
}

# Create a location with timezone
mutation {
  createLocation(input: {
    name: "Tokyo Office"
    city: "Tokyo"
    country: "Japan"
    timezone: "Asia/Tokyo"
  }) {
    id
    name
    timezone
  }
}

Supported Timezone Formats

  • UTC/GMT: "UTC", "GMT"
  • Americas: "America/New_York", "America/Los_Angeles"
  • Europe: "Europe/London", "Europe/Berlin"
  • Asia: "Asia/Tokyo", "Asia/Shanghai"
  • Australia: "Australia/Sydney"

This enhancement enables accurate time-series data interpretation by providing proper timezone context for sensor locations, which is essential for multi-timezone deployments.

Fixes #17.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: intui <15924901+intui@users.noreply.github.com>
Copilot AI changed the title [WIP] add timezone to sensor location object fields Add timezone field to Location model and GraphQL API Sep 16, 2025
Copilot AI requested a review from intui September 16, 2025 12:55
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

Successfully merging this pull request may close these issues.

add timezone to sensor location object fields

2 participants