Compare commits

..

2 commits

Author SHA1 Message Date
Mohammad Kanaan
22c7e0cdb6 annotate models
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
2026-05-25 19:15:06 +03:00
Mohammad Kanaan
5b56b091b4 add postgres with docker 2026-05-25 19:11:54 +03:00
28 changed files with 601 additions and 46 deletions

65
.annotaterb.yml Normal file
View file

@ -0,0 +1,65 @@
---
:position: before
:position_in_additional_file_patterns: before
:position_in_class: before
:position_in_factory: before
:position_in_fixture: before
:position_in_routes: before
:position_in_serializer: before
:position_in_test: before
:classified_sort: true
:exclude_controllers: true
:exclude_factories: false
:exclude_fixtures: false
:exclude_helpers: true
:exclude_scaffolds: true
:exclude_serializers: false
:exclude_sti_subclasses: false
:exclude_tests: false
:force: false
:format_markdown: false
:format_rdoc: false
:format_yard: false
:frozen: false
:grouped_polymorphic: false
:ignore_model_sub_dir: false
:ignore_unknown_models: false
:include_version: false
:show_check_constraints: false
:show_complete_foreign_keys: false
:show_foreign_keys: true
:show_indexes: true
:show_indexes_include: false
:simple_indexes: false
:sort: false
:timestamp: false
:trace: false
:with_comment: true
:with_column_comments: true
:with_table_comments: true
:position_of_column_comment: :with_name
:active_admin: false
:command:
:debug: false
:hide_default_column_types: ''
:hide_limit_column_types: ''
:timestamp_columns:
- created_at
- updated_at
:ignore_columns:
:ignore_routes:
:ignore_multi_database_name: false
:models: true
:routes: false
:skip_on_db_migrate: false
:target_action: :do_annotations
:wrapper:
:wrapper_close:
:wrapper_open:
:classes_default_to_s: []
:additional_file_patterns: []
:model_dir:
- app/models
:require: []
:root_dir:
- ''

View file

@ -2,8 +2,8 @@ source "https://rubygems.org"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.0.4"
# Use sqlite3 as the database for Active Record
gem "sqlite3", ">= 2.1"
# Use pg as the database for Active Record
gem "pg", "~> 1.5"
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
@ -44,4 +44,9 @@ group :development, :test do
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false
gem 'rails-erd', require: false
gem "annotaterb"
gem "dotenv-rails"
end

View file

@ -72,6 +72,9 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
annotaterb (4.22.0)
activerecord (>= 6.0.0)
activesupport (>= 6.0.0)
ast (2.4.3)
base64 (0.3.0)
bcrypt_pbkdf (1.1.2)
@ -82,6 +85,7 @@ GEM
brakeman (8.0.4)
racc
builder (3.3.0)
choice (0.2.0)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
crass (1.0.6)
@ -90,6 +94,9 @@ GEM
irb (~> 1.10)
reline (>= 0.3.8)
dotenv (3.2.0)
dotenv-rails (3.2.0)
dotenv (= 3.2.0)
railties (>= 6.1)
drb (2.2.3)
ed25519 (1.4.0)
erb (6.0.4)
@ -173,6 +180,12 @@ GEM
parser (3.3.11.1)
ast (~> 2.4.1)
racc
pg (1.6.3)
pg (1.6.3-aarch64-linux)
pg (1.6.3-aarch64-linux-musl)
pg (1.6.3-arm64-darwin)
pg (1.6.3-x86_64-linux)
pg (1.6.3-x86_64-linux-musl)
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
@ -210,6 +223,11 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-erd (1.7.2)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.7.0)
loofah (~> 2.25)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
@ -231,6 +249,7 @@ GEM
regexp_parser (2.12.0)
reline (0.6.3)
io-console (~> 0.5)
rexml (3.4.4)
rubocop (1.86.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
@ -259,6 +278,8 @@ GEM
rubocop (>= 1.72)
rubocop-performance (>= 1.24)
rubocop-rails (>= 2.30)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.13.0)
securerandom (0.4.1)
solid_cable (3.0.12)
@ -277,13 +298,6 @@ GEM
fugit (~> 1.11)
railties (>= 7.1)
thor (>= 1.3.1)
sqlite3 (2.9.4-aarch64-linux-gnu)
sqlite3 (2.9.4-aarch64-linux-musl)
sqlite3 (2.9.4-arm-linux-gnu)
sqlite3 (2.9.4-arm-linux-musl)
sqlite3 (2.9.4-arm64-darwin)
sqlite3 (2.9.4-x86_64-linux-gnu)
sqlite3 (2.9.4-x86_64-linux-musl)
sshkit (1.25.0)
base64
logger
@ -324,17 +338,20 @@ PLATFORMS
x86_64-linux-musl
DEPENDENCIES
annotaterb
bootsnap
brakeman
debug
dotenv-rails
kamal
pg (~> 1.5)
puma (>= 5.0)
rails (~> 8.0.4)
rails-erd
rubocop-rails-omakase
solid_cable
solid_cache
solid_queue
sqlite3 (>= 2.1)
thruster
tzinfo-data

View file

@ -1,2 +1,17 @@
# == Schema Information
#
# Table name: admins
#
# id :bigint not null, primary key
# email :string
# name :string
# password_digest :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_admins_on_email (email) UNIQUE
#
class Admin < ApplicationRecord
end

View file

@ -1,3 +1,12 @@
# == Schema Information
#
# Table name: chains
#
# id :bigint not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
class Chain < ApplicationRecord
has_one_attached :image
end

View file

@ -1,2 +1,12 @@
# == Schema Information
#
# Table name: guests
#
# id :bigint not null, primary key
# name :string
# username :string
# created_at :datetime not null
# updated_at :datetime not null
#
class Guest < ApplicationRecord
end

View file

@ -1,3 +1,24 @@
# == Schema Information
#
# Table name: moderation_logs
#
# id :bigint not null, primary key
# moderatable_type :string not null
# reason :string
# created_at :datetime not null
# updated_at :datetime not null
# admin_id :integer not null
# moderatable_id :integer not null
#
# Indexes
#
# index_moderation_logs_on_admin_id (admin_id)
# index_moderation_logs_on_moderatable (moderatable_type,moderatable_id)
#
# Foreign Keys
#
# fk_rails_... (admin_id => admins.id)
#
class ModerationLog < ApplicationRecord
belongs_to :moderatable, polymorphic: true
belongs_to :admin

View file

@ -1,3 +1,31 @@
# == Schema Information
#
# Table name: price_reports
#
# id :bigint not null, primary key
# discount_price :decimal(, )
# downvotes :integer
# price :decimal(, )
# reported_at :datetime
# upvotes :integer
# created_at :datetime not null
# updated_at :datetime not null
# guest_id :integer not null
# product_id :integer not null
# store_id :integer not null
#
# Indexes
#
# index_price_reports_on_guest_id (guest_id)
# index_price_reports_on_product_id (product_id)
# index_price_reports_on_store_id (store_id)
#
# Foreign Keys
#
# fk_rails_... (guest_id => guests.id)
# fk_rails_... (product_id => products.id)
# fk_rails_... (store_id => stores.id)
#
class PriceReport < ApplicationRecord
belongs_to :product
belongs_to :store

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: products
#
# id :bigint not null, primary key
# barcode :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_products_on_barcode (barcode) UNIQUE
#
class Product < ApplicationRecord
has_one_attached :image
end

View file

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: stores
#
# id :bigint not null, primary key
# latitude :float
# longitude :float
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# chain_id :integer not null
#
# Indexes
#
# index_stores_on_chain_id (chain_id)
#
# Foreign Keys
#
# fk_rails_... (chain_id => chains.id)
#
class Store < ApplicationRecord
has_one_attached :image
belongs_to :chain

View file

@ -1,41 +1,20 @@
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem "sqlite3"
#
default: &default
adapter: sqlite3
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
host: <%= ENV.fetch("DATABASE_HOST", "localhost") %>
port: <%= ENV.fetch("DATABASE_PORT", 5432) %>
username: <%= ENV.fetch("DATABASE_USER", "postgres") %>
password: <%= ENV.fetch("DATABASE_PASSWORD", "password") %>
development:
<<: *default
database: storage/development.sqlite3
database: price_point_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: storage/test.sqlite3
database: price_point_test
# Store production database in the storage/ directory, which by default
# is mounted as a persistent Docker volume in config/deploy.yml.
production:
primary:
<<: *default
database: storage/production.sqlite3
cache:
<<: *default
database: storage/production_cache.sqlite3
migrations_paths: db/cache_migrate
queue:
<<: *default
database: storage/production_queue.sqlite3
migrations_paths: db/queue_migrate
cable:
<<: *default
database: storage/production_cable.sqlite3
migrations_paths: db/cable_migrate
database: price_point_production

119
db/schema.rb generated Normal file
View file

@ -0,0 +1,119 @@
# 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.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2026_05_17_111138) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
t.bigint "record_id", null: false
t.bigint "blob_id", null: false
t.datetime "created_at", null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
end
create_table "active_storage_blobs", force: :cascade do |t|
t.string "key", null: false
t.string "filename", null: false
t.string "content_type"
t.text "metadata"
t.string "service_name", null: false
t.bigint "byte_size", null: false
t.string "checksum"
t.datetime "created_at", null: false
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end
create_table "active_storage_variant_records", force: :cascade do |t|
t.bigint "blob_id", null: false
t.string "variation_digest", null: false
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
create_table "admins", force: :cascade do |t|
t.string "name"
t.string "email"
t.string "password_digest"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_admins_on_email", unique: true
end
create_table "chains", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "guests", force: :cascade do |t|
t.string "username"
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "moderation_logs", force: :cascade do |t|
t.string "reason"
t.string "moderatable_type", null: false
t.integer "moderatable_id", null: false
t.integer "admin_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["admin_id"], name: "index_moderation_logs_on_admin_id"
t.index ["moderatable_type", "moderatable_id"], name: "index_moderation_logs_on_moderatable"
end
create_table "price_reports", force: :cascade do |t|
t.decimal "price"
t.decimal "discount_price"
t.integer "upvotes"
t.integer "downvotes"
t.datetime "reported_at"
t.integer "product_id", null: false
t.integer "store_id", null: false
t.integer "guest_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["guest_id"], name: "index_price_reports_on_guest_id"
t.index ["product_id"], name: "index_price_reports_on_product_id"
t.index ["store_id"], name: "index_price_reports_on_store_id"
end
create_table "products", force: :cascade do |t|
t.string "name"
t.string "barcode"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["barcode"], name: "index_products_on_barcode", unique: true
end
create_table "stores", force: :cascade do |t|
t.string "name"
t.float "latitude"
t.float "longitude"
t.integer "chain_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["chain_id"], name: "index_stores_on_chain_id"
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "moderation_logs", "admins"
add_foreign_key "price_reports", "guests"
add_foreign_key "price_reports", "products"
add_foreign_key "price_reports", "stores"
add_foreign_key "stores", "chains"
end

13
docker-compose.yml Normal file
View file

@ -0,0 +1,13 @@
services:
db:
image: postgres:17
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:

View file

@ -0,0 +1,10 @@
# This rake task was added by annotate_rb gem.
# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this
if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil?
require "annotate_rb"
# Can modify the config path here if needed - by default, it's .annotaterb.yml in the root of the project
# AnnotateRb::ConfigFinder.config_path = ""
AnnotateRb::Core.load_rake_tasks
end

View file

@ -1,5 +1,20 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: admins
#
# id :bigint not null, primary key
# email :string
# name :string
# password_digest :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_admins_on_email (email) UNIQUE
#
one:
name: MyString
email: MyString

View file

@ -1,5 +1,14 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: chains
#
# id :bigint not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
one:
name: MyString

View file

@ -1,5 +1,15 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: guests
#
# id :bigint not null, primary key
# name :string
# username :string
# created_at :datetime not null
# updated_at :datetime not null
#
one:
username: MyString
name: MyString

View file

@ -1,5 +1,26 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: moderation_logs
#
# id :bigint not null, primary key
# moderatable_type :string not null
# reason :string
# created_at :datetime not null
# updated_at :datetime not null
# admin_id :integer not null
# moderatable_id :integer not null
#
# Indexes
#
# index_moderation_logs_on_admin_id (admin_id)
# index_moderation_logs_on_moderatable (moderatable_type,moderatable_id)
#
# Foreign Keys
#
# fk_rails_... (admin_id => admins.id)
#
one:
reason: MyString
moderatable: one

View file

@ -1,5 +1,33 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: price_reports
#
# id :bigint not null, primary key
# discount_price :decimal(, )
# downvotes :integer
# price :decimal(, )
# reported_at :datetime
# upvotes :integer
# created_at :datetime not null
# updated_at :datetime not null
# guest_id :integer not null
# product_id :integer not null
# store_id :integer not null
#
# Indexes
#
# index_price_reports_on_guest_id (guest_id)
# index_price_reports_on_product_id (product_id)
# index_price_reports_on_store_id (store_id)
#
# Foreign Keys
#
# fk_rails_... (guest_id => guests.id)
# fk_rails_... (product_id => products.id)
# fk_rails_... (store_id => stores.id)
#
one:
price: 9.99
discount_price: 9.99

View file

@ -1,9 +1,19 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: products
#
# id :bigint not null, primary key
# barcode :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_products_on_barcode (barcode) UNIQUE
#
one:
name: MyString
barcode: MyString
two:
name: MyString
barcode: MyString

View file

@ -1,5 +1,25 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# == Schema Information
#
# Table name: stores
#
# id :bigint not null, primary key
# latitude :float
# longitude :float
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# chain_id :integer not null
#
# Indexes
#
# index_stores_on_chain_id (chain_id)
#
# Foreign Keys
#
# fk_rails_... (chain_id => chains.id)
#
one:
name: MyString
latitude: 1.5

View file

@ -1,3 +1,18 @@
# == Schema Information
#
# Table name: admins
#
# id :bigint not null, primary key
# email :string
# name :string
# password_digest :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_admins_on_email (email) UNIQUE
#
require "test_helper"
class AdminTest < ActiveSupport::TestCase

View file

@ -1,3 +1,12 @@
# == Schema Information
#
# Table name: chains
#
# id :bigint not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
require "test_helper"
class ChainTest < ActiveSupport::TestCase

View file

@ -1,3 +1,13 @@
# == Schema Information
#
# Table name: guests
#
# id :bigint not null, primary key
# name :string
# username :string
# created_at :datetime not null
# updated_at :datetime not null
#
require "test_helper"
class GuestTest < ActiveSupport::TestCase

View file

@ -1,3 +1,24 @@
# == Schema Information
#
# Table name: moderation_logs
#
# id :bigint not null, primary key
# moderatable_type :string not null
# reason :string
# created_at :datetime not null
# updated_at :datetime not null
# admin_id :integer not null
# moderatable_id :integer not null
#
# Indexes
#
# index_moderation_logs_on_admin_id (admin_id)
# index_moderation_logs_on_moderatable (moderatable_type,moderatable_id)
#
# Foreign Keys
#
# fk_rails_... (admin_id => admins.id)
#
require "test_helper"
class ModerationLogTest < ActiveSupport::TestCase

View file

@ -1,3 +1,31 @@
# == Schema Information
#
# Table name: price_reports
#
# id :bigint not null, primary key
# discount_price :decimal(, )
# downvotes :integer
# price :decimal(, )
# reported_at :datetime
# upvotes :integer
# created_at :datetime not null
# updated_at :datetime not null
# guest_id :integer not null
# product_id :integer not null
# store_id :integer not null
#
# Indexes
#
# index_price_reports_on_guest_id (guest_id)
# index_price_reports_on_product_id (product_id)
# index_price_reports_on_store_id (store_id)
#
# Foreign Keys
#
# fk_rails_... (guest_id => guests.id)
# fk_rails_... (product_id => products.id)
# fk_rails_... (store_id => stores.id)
#
require "test_helper"
class PriceReportTest < ActiveSupport::TestCase

View file

@ -1,3 +1,17 @@
# == Schema Information
#
# Table name: products
#
# id :bigint not null, primary key
# barcode :string
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_products_on_barcode (barcode) UNIQUE
#
require "test_helper"
class ProductTest < ActiveSupport::TestCase

View file

@ -1,3 +1,23 @@
# == Schema Information
#
# Table name: stores
#
# id :bigint not null, primary key
# latitude :float
# longitude :float
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# chain_id :integer not null
#
# Indexes
#
# index_stores_on_chain_id (chain_id)
#
# Foreign Keys
#
# fk_rails_... (chain_id => chains.id)
#
require "test_helper"
class StoreTest < ActiveSupport::TestCase