-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from Freika/zones_and_visits
Areas and visits
- Loading branch information
Showing
61 changed files
with
1,556 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.9.4 | ||
0.9.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
MAPBOX_ACCESS_TOKEN=MAPBOX_ACCESS_TOKEN | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,72 @@ | ||
# .github/workflows/ruby.yml | ||
name: Ruby | ||
name: CI | ||
# Not functional at the moment | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
env: | ||
POSTGRES_DB: postgres | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: password | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: postgres:12 | ||
image: postgres | ||
env: | ||
POSTGRES_PASSWORD: password | ||
ports: ['5432:5432'] | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
redis: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
|
||
steps: | ||
- name: Install packages | ||
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips postgresql-client libpq-dev | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Ruby | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.2.3 | ||
ruby-version: '3.2.3' | ||
bundler-cache: true | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update && sudo apt-get -yqq install libpq-dev | ||
bundle install --jobs 4 --retry 3 | ||
- name: Run Tests | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16' # Use the appropriate Node.js version | ||
|
||
- name: Install Node.js dependencies | ||
run: npm install | ||
|
||
- name: Install Ruby dependencies | ||
run: bundle install | ||
|
||
- name: Run tests | ||
env: | ||
RAILS_ENV: test | ||
PGHOST: localhost | ||
DISABLE_SPRING: 1 | ||
DATABASE_URL: postgres://postgres:postgres@localhost:5432 | ||
REDIS_URL: redis://localhost:6379/1 | ||
run: | | ||
cp config/database.ci.yml config/database.yml | ||
bundle exec rails db:schema:load | ||
bundle exec rspec --format progress | ||
bin/rails db:setup | ||
bin/rails spec || (cat log/test.log && exit 1) | ||
- name: Keep screenshots from failed system tests | ||
uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: screenshots | ||
path: ${{ github.workspace }}/tmp/capybara | ||
if-no-files-found: ignore | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ruby-3 | ||
3.2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::V1::AreasController < ApplicationController | ||
before_action :authenticate_api_key | ||
before_action :set_area, only: %i[update destroy] | ||
|
||
def index | ||
@areas = current_api_user.areas | ||
|
||
render json: @areas, status: :ok | ||
end | ||
|
||
def create | ||
@area = current_api_user.areas.build(area_params) | ||
|
||
if @area.save | ||
render json: @area, status: :created | ||
else | ||
render json: { errors: @area.errors.full_messages }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def update | ||
if @area.update(area_params) | ||
render json: @area, status: :ok | ||
else | ||
render json: { errors: @area.errors.full_messages }, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy | ||
@area.destroy! | ||
|
||
render json: { message: 'Area was successfully deleted' }, status: :ok | ||
end | ||
|
||
private | ||
|
||
def set_area | ||
@area = current_api_user.areas.find(params[:id]) | ||
end | ||
|
||
def area_params | ||
params.require(:area).permit(:name, :latitude, :longitude, :radius) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
class VisitsController < ApplicationController | ||
before_action | ||
before_action :set_visit, only: %i[update] | ||
|
||
def index | ||
visits = current_user | ||
.visits | ||
.where(status: :pending) | ||
.or(current_user.visits.where(status: :confirmed)) | ||
.order(started_at: :asc) | ||
.group_by { |visit| visit.started_at.to_date } | ||
.map { |k, v| { date: k, visits: v } } | ||
|
||
@visits = Kaminari.paginate_array(visits).page(params[:page]).per(10) | ||
end | ||
|
||
def update | ||
if @visit.update(visit_params) | ||
redirect_to visits_url, notice: 'Visit was successfully updated.', status: :see_other | ||
else | ||
render :edit, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_visit | ||
@visit = current_user.visits.find(params[:id]) | ||
end | ||
|
||
def visit_params | ||
params.require(:visit).permit(:name, :started_at, :ended_at, :status) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.