-
Notifications
You must be signed in to change notification settings - Fork 23
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 #15 from TelosLabs/improvements-modeling
Improvements | Modeling
- Loading branch information
Showing
39 changed files
with
747 additions
and
84 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
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
# == Schema Information | ||
# | ||
# Table name: conferences | ||
# | ||
# id :integer not null, primary key | ||
# name :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
class Conference < ApplicationRecord | ||
has_many :events, dependent: :destroy | ||
has_many :locations, dependent: :destroy | ||
has_many :events, dependent: :destroy | ||
|
||
validates :name, presence: true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,33 @@ | ||
# == Schema Information | ||
# | ||
# Table name: events | ||
# | ||
# id :integer not null, primary key | ||
# description :string | ||
# ends_at :datetime not null | ||
# starts_at :datetime not null | ||
# title :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# conference_id :integer not null | ||
# location_id :integer not null | ||
# | ||
# Indexes | ||
# | ||
# index_events_on_conference_id (conference_id) | ||
# index_events_on_location_id (location_id) | ||
# | ||
class Event < ApplicationRecord | ||
belongs_to :location | ||
belongs_to :conference | ||
|
||
has_many :event_tags, dependent: :destroy | ||
has_many :saved_events, dependent: :destroy | ||
has_many :speakers, dependent: :destroy | ||
has_many :tags, through: :event_tags | ||
has_many :users, through: :saved_events | ||
has_and_belongs_to_many :speakers | ||
has_and_belongs_to_many :users # attendees | ||
has_and_belongs_to_many :tags | ||
|
||
validates :title, presence: true | ||
validates :starts_at, presence: true | ||
validates :ends_at, presence: true | ||
|
||
validates_datetime :ends_at, after: :starts_at | ||
end |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
# == Schema Information | ||
# | ||
# Table name: locations | ||
# | ||
# id :integer not null, primary key | ||
# name :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# conference_id :integer not null | ||
# | ||
# Indexes | ||
# | ||
# index_locations_on_conference_id (conference_id) | ||
# index_locations_on_name_and_conference_id (name,conference_id) UNIQUE | ||
# | ||
class Location < ApplicationRecord | ||
belongs_to :conference | ||
|
||
has_many :events, dependent: :destroy | ||
|
||
validates :name, presence: true, uniqueness: {scope: :conference_id} | ||
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
# == Schema Information | ||
# | ||
# Table name: speakers | ||
# | ||
# id :integer not null, primary key | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
class Speaker < ApplicationRecord | ||
belongs_to :event | ||
|
||
has_one :profile, as: :profileable, dependent: :destroy | ||
|
||
has_and_belongs_to_many :events | ||
|
||
accepts_nested_attributes_for :profile | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
# == Schema Information | ||
# | ||
# Table name: tags | ||
# | ||
# id :integer not null, primary key | ||
# name :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_tags_on_name (name) UNIQUE | ||
# | ||
class Tag < ApplicationRecord | ||
has_many :event_tags, dependent: :destroy | ||
has_many :events, through: :event_tags | ||
has_and_belongs_to_many :events | ||
|
||
validates :name, presence: true, uniqueness: true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
# == Schema Information | ||
# | ||
# Table name: users | ||
# | ||
# id :integer not null, primary key | ||
# email :string not null | ||
# in_app_notifications_enabled :boolean default(TRUE), not null | ||
# mail_notifications_enabled :boolean default(TRUE), not null | ||
# role :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_users_on_email (email) UNIQUE | ||
# | ||
class User < ApplicationRecord | ||
normalizes :email, with: ->(email) { email.strip.downcase } | ||
|
||
has_one :profile, as: :profileable, dependent: :destroy | ||
|
||
has_many :saved_events, dependent: :destroy | ||
has_many :events, through: :saved_events | ||
has_and_belongs_to_many :events | ||
|
||
validates :email, presence: true, uniqueness: true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ValidatesTimeliness.setup do |config| | ||
# Extend ORM/ODMs for full support (:active_record included). | ||
config.extend_orms = [:active_record] | ||
# | ||
# Default timezone | ||
# config.default_timezone = :utc | ||
# | ||
# Set the dummy date part for a time type values. | ||
# config.dummy_date_for_time_type = [ 2000, 1, 1 ] | ||
# | ||
# Ignore errors when restriction options are evaluated | ||
# config.ignore_restriction_errors = false | ||
# | ||
# Re-display invalid values in date/time selects | ||
# config.enable_date_time_select_extension! | ||
# | ||
# Handle multiparameter date/time values strictly | ||
# config.enable_multiparameter_extension! | ||
# | ||
# Shorthand date and time symbols for restrictions | ||
# config.restriction_shorthand_symbols.update( | ||
# :now => lambda { Time.current }, | ||
# :today => lambda { Date.current } | ||
# ) | ||
# | ||
# Use the plugin date/time parser which is stricter and extendable | ||
# config.use_plugin_parser = false | ||
# | ||
# Add one or more formats making them valid. e.g. add_formats(:date, 'd(st|rd|th) of mmm, yyyy') | ||
# config.parser.add_formats() | ||
# | ||
# Remove one or more formats making them invalid. e.g. remove_formats(:date, 'dd/mm/yyy') | ||
# config.parser.remove_formats() | ||
# | ||
# Change the ambiguous year threshold when parsing a 2 digit year | ||
# config.parser.ambiguous_year_threshold = 30 | ||
# | ||
# Treat ambiguous dates, such as 01/02/1950, as a Non-US date. | ||
# config.parser.remove_us_formats | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
en: | ||
errors: | ||
messages: | ||
invalid_date: "is not a valid date" | ||
invalid_time: "is not a valid time" | ||
invalid_datetime: "is not a valid datetime" | ||
is_at: "must be at %{restriction}" | ||
before: "must be before %{restriction}" | ||
on_or_before: "must be on or before %{restriction}" | ||
after: "must be after %{restriction}" | ||
on_or_after: "must be on or after %{restriction}" | ||
validates_timeliness: | ||
error_value_formats: | ||
date: '%Y-%m-%d' | ||
time: '%H:%M:%S' | ||
datetime: '%Y-%m-%d %H:%M:%S' |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
class CreateLocations < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :locations do |t| | ||
t.string :name | ||
t.string :name, null: false | ||
t.references :conference, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
|
||
t.index %i[name conference_id], unique: true | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
class CreateTags < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :tags do |t| | ||
t.string :name | ||
t.string :name, null: false | ||
|
||
t.timestamps | ||
|
||
t.index :name, unique: true | ||
end | ||
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
6 changes: 4 additions & 2 deletions
6
...grate/20240628205111_create_event_tags.rb → ...rate/20240628205111_create_events_tags.rb
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,10 +1,12 @@ | ||
class CreateEventTags < ActiveRecord::Migration[7.1] | ||
class CreateEventsTags < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :event_tags do |t| | ||
create_table :events_tags do |t| | ||
t.references :event, null: false, foreign_key: true | ||
t.references :tag, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
|
||
t.index %i[event_id tag_id], unique: true | ||
end | ||
end | ||
end |
Oops, something went wrong.