Add copyright notice
All checks were successful
Add copyright notice / copyright_notice (pull_request) Successful in 3m21s
Run unit tests / unit_tests (pull_request) Successful in 2m49s
Build Nginx-based docker image / build-static-assets (pull_request) Successful in 31m54s

This commit is contained in:
Manuel Bustillo 2024-10-27 21:42:45 +00:00
parent f3172bb38f
commit b7cabc1661
80 changed files with 160 additions and 0 deletions

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
module ApplicationCable
class Channel < ActionCable::Channel::Base
end

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
module ApplicationCable
class Connection < ActionCable::Connection::Base
end

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class ApplicationController < ActionController::Base
after_action :set_csrf_cookie

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class ExpensesController < ApplicationController
before_action :set_expense, only: %i[ show edit update destroy ]

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class GroupsController < ApplicationController
def index
roots = Group.where(parent_id: nil)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
require 'csv'
class GuestsController < ApplicationController

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class TablesArrangementsController < ApplicationController
def index
@tables_arrangements = TablesArrangement.all.order(discomfort: :asc).limit(10)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
module TreeNodeExtension
def distance_to_common_ancestor(another_node)
return 0 if self == another_node

View File

@ -1,2 +1,4 @@
# Copyright (C) 2024 Manuel Bustillo
module ApplicationHelper
end

View File

@ -1,2 +1,4 @@
# Copyright (C) 2024 Manuel Bustillo
module ExpensesHelper
end

View File

@ -1,2 +1,4 @@
# Copyright (C) 2024 Manuel Bustillo
module GroupsHelper
end

View File

@ -1,2 +1,4 @@
# Copyright (C) 2024 Manuel Bustillo
module GuestsHelper
end

View File

@ -1,2 +1,4 @@
# Copyright (C) 2024 Manuel Bustillo
module TablesArrangementsHelper
end

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout "mailer"

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end

View File

@ -1,2 +1,4 @@
# Copyright (C) 2024 Manuel Bustillo
class Expense < ApplicationRecord
end

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class Group < ApplicationRecord
validates :name, uniqueness: true
validates :name, :order, presence: true

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class Guest < ApplicationRecord
acts_as_taggable_on :affinity_groups, :unbreakable_bonds
belongs_to :group

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class Seat < ApplicationRecord
belongs_to :guest
belongs_to :table_arrangement

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class TablesArrangement < ApplicationRecord
has_many :seats
end

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class SerializableGroup < JSONAPI::Serializable::Resource
type 'group'

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class SerializableGuest < JSONAPI::Serializable::Resource
type 'guest'

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class AffinityGroupsHierarchy < Array
include Singleton

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
module Tables
class DiscomfortCalculator
private attr_reader :table

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
require_relative '../../extensions/tree_node_extension'
module Tables

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
module Tables
class Swap
private attr_reader :initial_solution

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
module Tables
class Table < Array
attr_accessor :discomfort

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
module VNS
class Engine
def target_function(&function)

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<div id="<%= dom_id expense %>">
<p>
<strong>Name:</strong>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<%= form_with(model: expense) do |form| %>
<% if expense.errors.any? %>
<div style="color: red">

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<h1>Editing expense</h1>
<%= render "form", expense: @expense %>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<p style="color: green"><%= notice %></p>
<h1>Expenses</h1>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<h1>New expense</h1>
<%= render "form", expense: @expense %>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<p style="color: green"><%= notice %></p>
<%= render @expense %>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<%= form_with(model: guest) do |form| %>
<% if guest.errors.any? %>
<div style="color: red">

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<div id="<%= dom_id guest %>">
<p>
<strong>First name:</strong>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<h1>Editing guest</h1>
<%= render "form", guest: @guest %>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<p style="color: green"><%= notice %></p>
<h1>Guests</h1>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<h1>New guest</h1>
<%= render "form", guest: @guest %>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<p style="color: green"><%= notice %></p>
<%= render @guest %>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<!DOCTYPE html>
<html>
<head>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<!DOCTYPE html>
<html>
<head>

View File

@ -1 +1,3 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<%= yield %>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<h1>Tables arrangements</h1>
<ol>

View File

@ -1,3 +1,5 @@
<%# Copyright (C) 2024 Manuel Bustillo %>
<h1>ID: <%= @tables_arrangement.id %></h1>
<p>Discomfort: <%= @tables_arrangement.discomfort %></p>

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
require_relative 'boot'
require 'rails'

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" # Set up gems listed in the Gemfile.

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# Load the Rails application.
require_relative "application"

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
require "active_support/core_ext/integer/time"
Rails.application.configure do

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
require "active_support/core_ext/integer/time"
Rails.application.configure do

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
require "active_support/core_ext/integer/time"
# The test environment is used exclusively to run your application's

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# Pin npm packages by running ./bin/importmap
pin "application"

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
require_relative '../../app/services/affinity_groups_hierarchy'
hierarchy = AffinityGroupsHierarchy.instance

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy.

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# config/initializers/cors.rb
Rails.application.config.middleware.insert_before 0, Rack::Cors do

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# Be sure to restart your server when you modify this file.
# Define an application-wide HTTP permissions policy. For further

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class Numeric
def to_currency
Money.from_amount(self, "EUR").format

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
Rails.application.routes.draw do
resources :groups, only: :index
resources :guests do

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class CreateExpenses < ActiveRecord::Migration[7.1]
def change
create_enum :pricing_types, ["fixed", "per_person"]

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class CreateGuests < ActiveRecord::Migration[7.1]
def change
create_table :guests, id: :uuid do |t|

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# frozen_string_literal: true
# This migration comes from acts_as_taggable_on_engine (originally 1)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# frozen_string_literal: true
# This migration comes from acts_as_taggable_on_engine (originally 2)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# frozen_string_literal: true
# This migration comes from acts_as_taggable_on_engine (originally 3)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# frozen_string_literal: true
# This migration comes from acts_as_taggable_on_engine (originally 4)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# frozen_string_literal: true
# This migration comes from acts_as_taggable_on_engine (originally 5)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# frozen_string_literal: true
# This migration comes from acts_as_taggable_on_engine (originally 6)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# frozen_string_literal: true
# This migration comes from acts_as_taggable_on_engine (originally 7)

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class CreateTablesArrangements < ActiveRecord::Migration[7.1]
def change
create_table :tables_arrangements, id: :uuid do |t|

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class CreateSeats < ActiveRecord::Migration[7.1]
def change
create_table :seats, id: :uuid do |t|

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class CreateGroups < ActiveRecord::Migration[7.1]
def change
create_table :groups, id: :uuid do |t|

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class AddParentToGroup < ActiveRecord::Migration[7.1]
def change
add_reference :groups, :parent, type: :uuid, index: true, foreign_key: { to_table: :groups }

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class AddGroupToGuest < ActiveRecord::Migration[7.1]
def change
add_reference :guests, :group, null: false, foreign_key: true, type: :uuid

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
class AddStatusToGuest < ActiveRecord::Migration[7.1]
def change
add_column :guests, :status, :integer, default: 0

2
db/schema.rb generated
View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.

View File

@ -1,3 +1,5 @@
# Copyright (C) 2024 Manuel Bustillo
NUMBER_OF_GUESTS = 50
TablesArrangement.delete_all