mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 10:17:55 -05:00
Add health check endpoint
This commit is contained in:
@@ -1 +1 @@
|
||||
0.13.0
|
||||
0.13.1
|
||||
|
||||
@@ -7,7 +7,7 @@ orbs:
|
||||
jobs:
|
||||
test:
|
||||
docker:
|
||||
- image: cimg/ruby:3.2.3
|
||||
- image: cimg/ruby:3.3.5
|
||||
environment:
|
||||
RAILS_ENV: test
|
||||
- image: circleci/postgres:13.3
|
||||
|
||||
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
- name: Set up Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '3.2.3'
|
||||
ruby-version: '3.3.5'
|
||||
bundler-cache: true
|
||||
|
||||
- name: Set up Node.js
|
||||
|
||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [0.13.1] — 2024-09-05
|
||||
|
||||
### Added
|
||||
|
||||
- `GET /api/v1/health` endpoint to check the health of the application with swagger docs
|
||||
|
||||
### Changed
|
||||
|
||||
- Ruby version updated to 3.3.5
|
||||
- Visits suggestion process now will try to merge consecutive visits to the same place into one visit.
|
||||
|
||||
|
||||
## [0.13.0] — 2024-09-03
|
||||
|
||||
The GPX and GeoJSON export release
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM ruby:3.2.3-alpine
|
||||
FROM ruby:3.3.5-alpine
|
||||
|
||||
ENV APP_PATH /var/app
|
||||
ENV BUNDLE_VERSION 2.5.9
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM ruby:3.2.3-alpine
|
||||
FROM ruby:3.3.5-alpine
|
||||
|
||||
ENV APP_PATH /var/app
|
||||
ENV BUNDLE_VERSION 2.5.9
|
||||
|
||||
1
Gemfile
1
Gemfile
@@ -47,7 +47,6 @@ group :test do
|
||||
gem 'shoulda-matchers'
|
||||
gem 'simplecov', require: false
|
||||
gem 'super_diff'
|
||||
gem 'timecop'
|
||||
gem 'webmock'
|
||||
end
|
||||
|
||||
|
||||
@@ -389,7 +389,6 @@ GEM
|
||||
tailwindcss-rails (2.7.3-x86_64-linux)
|
||||
railties (>= 7.0.0)
|
||||
thor (1.3.2)
|
||||
timecop (0.9.10)
|
||||
timeout (0.4.1)
|
||||
turbo-rails (2.0.6)
|
||||
actionpack (>= 6.0.0)
|
||||
@@ -458,7 +457,6 @@ DEPENDENCIES
|
||||
stimulus-rails
|
||||
super_diff
|
||||
tailwindcss-rails
|
||||
timecop
|
||||
turbo-rails
|
||||
tzinfo-data
|
||||
webmock
|
||||
|
||||
9
app/controllers/api/v1/health_controller.rb
Normal file
9
app/controllers/api/v1/health_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::HealthController < ApiController
|
||||
skip_before_action :authenticate_api_key
|
||||
|
||||
def index
|
||||
render json: { status: 'ok' }
|
||||
end
|
||||
end
|
||||
@@ -56,6 +56,7 @@ Rails.application.routes.draw do
|
||||
|
||||
namespace :api do
|
||||
namespace :v1 do
|
||||
get 'health', to: 'health#index'
|
||||
patch 'settings', to: 'settings#update'
|
||||
get 'settings', to: 'settings#index'
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
version: '3'
|
||||
networks:
|
||||
dawarich:
|
||||
services:
|
||||
|
||||
15
spec/requests/api/v1/health_spec.rb
Normal file
15
spec/requests/api/v1/health_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::V1::Healths', type: :request do
|
||||
describe 'GET /index' do
|
||||
context 'when user is not authenticated' do
|
||||
it 'returns http success' do
|
||||
get '/api/v1/health'
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -27,26 +27,22 @@ RSpec.describe Visits::Prepare do
|
||||
subject { described_class.new(points).call }
|
||||
|
||||
it 'returns correct visits' do
|
||||
freezed_time = Time.current
|
||||
|
||||
Timecop.freeze(freezed_time) do
|
||||
expect(subject).to eq [
|
||||
{
|
||||
date: 1.day.ago.to_date.to_s,
|
||||
visits: [
|
||||
{
|
||||
latitude: 0.0,
|
||||
longitude: 0.0,
|
||||
radius: 10,
|
||||
points:,
|
||||
duration: 105,
|
||||
started_at: 1.day.ago.to_s,
|
||||
ended_at: (1.day.ago + 105.minutes).to_s
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
end
|
||||
expect(subject).to eq [
|
||||
{
|
||||
date: 1.day.ago.to_date.to_s,
|
||||
visits: [
|
||||
{
|
||||
latitude: 0.0,
|
||||
longitude: 0.0,
|
||||
radius: 10,
|
||||
points:,
|
||||
duration: 105,
|
||||
started_at: 1.day.ago.to_s,
|
||||
ended_at: (1.day.ago + 105.minutes).to_s
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
15
spec/swagger/api/v1/health_controller_spec.rb
Normal file
15
spec/swagger/api/v1/health_controller_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'swagger_helper'
|
||||
|
||||
describe 'Health API', type: :request do
|
||||
path '/api/v1/health' do
|
||||
get 'Retrieves application status' do
|
||||
tags 'Health'
|
||||
produces 'application/json'
|
||||
response '200', 'areas found' do
|
||||
run_test!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -106,6 +106,14 @@ paths:
|
||||
responses:
|
||||
'200':
|
||||
description: area deleted
|
||||
"/api/v1/health":
|
||||
get:
|
||||
summary: Retrieves application status
|
||||
tags:
|
||||
- Health
|
||||
responses:
|
||||
'200':
|
||||
description: areas found
|
||||
"/api/v1/overland/batches":
|
||||
post:
|
||||
summary: Creates a batch of points
|
||||
|
||||
Reference in New Issue
Block a user