{"id":25351103,"url":"https://github.com/jmkoni/readings","last_synced_at":"2025-10-14T14:16:33.595Z","repository":{"id":233034122,"uuid":"754770251","full_name":"jmkoni/readings","owner":"jmkoni","description":"Wee little test project built with Sinatra","archived":false,"fork":false,"pushed_at":"2024-04-12T19:01:27.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-14T14:16:31.985Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmkoni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-08T18:28:15.000Z","updated_at":"2024-02-20T17:29:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"02c6603d-435c-4acf-922b-6a92c0da8d32","html_url":"https://github.com/jmkoni/readings","commit_stats":null,"previous_names":["jmkoni/readings"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jmkoni/readings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmkoni%2Freadings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmkoni%2Freadings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmkoni%2Freadings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmkoni%2Freadings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmkoni","download_url":"https://codeload.github.com/jmkoni/readings/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmkoni%2Freadings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019121,"owners_count":26086679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-14T17:38:43.151Z","updated_at":"2025-10-14T14:16:33.579Z","avatar_url":"https://github.com/jmkoni.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Readings API\n\nThis is a simple test app that stores \"reading\" data and returns it. It uses just a simple in-memory data store. It is built with Sinatra and tested using Rspec.\n\n## Ruby Version\n\n3.2.2\n\n## Running the app\n\nYou should be able to just run `bin/setup` to initialize the app and install any needed dependencies. If you are using RVM, it will use the `.ruby-gemset` and `.ruby-version` files to install the right ruby version and create a gemset for you when you enter the project directory. If you want to do it step by step:\n\n``` sh\nbundle install\npuma\n```\n\n## Endpoints\n\n### GET /cumulative/:id\n\nReturns the cumulative count of all readings for a given device. Pass in the id of the device in the request. Example:\n\n``` sh\nhttp://0.0.0.0:9292/cumulative/123-456 # 123-456 is the device id\n```\n\nExample response:\n\n``` json\n{ \"cumulative_count\": 23 }\n```\n\nA zero will be returned if no data exists.\n\n### GET /latest/:id\n\nReturns the latest timestamp of all readings for a given device. Pass in the id of the device in the request. Example:\n\n``` sh\nhttp://0.0.0.0:9292/cumulative/123-456 # 123-456 is the device id\n```\n\nExample response:\n\n``` json\n{ \"latest_timestamp\": \"2021-09-29T16:08:15+01:00\" }\n```\n\nA nil value will returned if no data exists.\n\n### POST /readings\n\nAdds readings to a given device. Expected request body:\n\n``` json\n{\n  \"id\": \"36d5658a-6908-479e-887e-a949ec199272\",\n  \"readings\":\n  [\n    {\n      \"timestamp\": \"2021-09-29T16:08:15+01:00\",\n      \"count\": 2\n    }, {\n      \"timestamp\": \"2021-09-29T16:09:15+01:00\",\n      \"count\": 15\n    }\n  ]\n}\n```\n\nTimestamps must be ISO-8061 standard. Count is expected as an integer, but \"1\" will be parsed as a 1. Any duplicate timestamp is ignored.\n\nExample response:\n\n``` json\n{ message: \"Reading created\" }\n```\nStatus: 201\n\n``` json\n{ message: \"Reading not created\" }\n```\nStatus: 400\n\n## General project structure\n\n``` sh\n- app # primary application code\n  - api # home for API\n  - models # currently home to Device model\n- config # set up environment\n- spec # home to tests\n  - api # request specs\n  - models # model specs\n```\n\n## Running the tests\n\nJust run `rspec`!\n\n## Potential Improvements\n\n- Device could be more along the lines of a traditional ActiveRecord model\n  - At that point, validations could be moved to an instance instead of embedded in the create method\n- Actually using a database would be useful. SQLite is probably the best option for this project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmkoni%2Freadings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmkoni%2Freadings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmkoni%2Freadings/lists"}