Add isRinging query to check alarm state via API
Features: - New GraphQL query 'isRinging' returns true/false if wecker is active - Checks the wecker process via PID file (PID_FILE in common.py) DRY refactoring: - Extract PID_FILE into shared common.py module - Both wecker.py and api/schema.py import from common - DRY enforcement tests verify identity (is) not just equality Tests: - test_is_ringing_returns_false_when_not_running - test_is_ringing_returns_true_when_running - test_pid_file_defined_once_across_modules (DRY enforcement) - test_pid_file_same_shared_constant_in_api (DRY enforcement) - Cleaned up unused imports in test_single_instance.py Docs: - Updated README.md with isRinging query documentation
This commit is contained in:
@@ -57,6 +57,14 @@ Instead of manually editing your crontab, this project provides a simple GraphQL
|
||||
|
||||
### Example API Usage
|
||||
|
||||
**Check if alarm is currently ringing:**
|
||||
```graphql
|
||||
query {
|
||||
isRinging
|
||||
}
|
||||
```
|
||||
Returns `true` if the wecker alarm clock is currently active (playing music), `false` otherwise.
|
||||
|
||||
**Get all alarms:**
|
||||
```graphql
|
||||
query {
|
||||
@@ -92,6 +100,15 @@ mutation {
|
||||
```
|
||||
|
||||
|
||||
### Example response for `isRinging`:
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"isRinging": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## How the Puzzle Works
|
||||
1. **Ringing:** The music plays in an endless loop.
|
||||
2. **Start:** Press the arcade button once to start the puzzle. Wait 3 seconds.
|
||||
|
||||
Reference in New Issue
Block a user