Skip to content
Snippets Groups Projects
Unverified Commit d7a6b04b authored by Samuel Couillard's avatar Samuel Couillard Committed by GitHub
Browse files

Add recorded_at Column to Recordings (#4900)


* Add Meeting Date column to Recordings

* Rename column from meeting_date to recorded_at

* Remove non-nullable

* Fix specs

---------

Co-authored-by: default avatarAhmad Farhat <ahmad.af.farhat@gmail.com>
parent 56dbb005
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ module Api
def index
sort_config = config_sorting(allowed_columns: %w[name length visibility])
pagy, recordings = pagy(current_user.recordings&.order(sort_config, created_at: :desc)&.search(params[:search]))
pagy, recordings = pagy(current_user.recordings&.order(sort_config, recorded_at: :desc)&.search(params[:search]))
render_data data: recordings, meta: pagy_metadata(pagy), status: :ok
end
......
......@@ -132,7 +132,7 @@ module Api
def recordings
sort_config = config_sorting(allowed_columns: %w[name length visibility])
pagy, room_recordings = pagy(@room.recordings&.order(sort_config, created_at: :desc)&.search(params[:q]))
pagy, room_recordings = pagy(@room.recordings&.order(sort_config, recorded_at: :desc)&.search(params[:q]))
render_data data: room_recordings, meta: pagy_metadata(pagy), status: :ok
end
......
......@@ -48,7 +48,7 @@ export default function RecordingRow({
const [isEditing, setIsEditing] = useState(false);
const [isUpdating, setIsUpdating] = useState(false);
const currentUser = useAuth();
const localizedTime = localizeDateTimeString(recording?.created_at, currentUser?.language);
const localizedTime = localizeDateTimeString(recording?.recorded_at, currentUser?.language);
const formats = recording.formats.sort(
(a, b) => (a.recording_type.toLowerCase() > b.recording_type.toLowerCase() ? 1 : -1),
);
......@@ -186,7 +186,7 @@ RecordingRow.propTypes = {
})),
visibility: PropTypes.string.isRequired,
protectable: PropTypes.bool,
created_at: PropTypes.string.isRequired,
recorded_at: PropTypes.string.isRequired,
map: PropTypes.func,
}).isRequired,
visibilityMutation: PropTypes.func.isRequired,
......
......@@ -26,6 +26,7 @@ class Recording < ApplicationRecord
validates :visibility, presence: true
validates :length, presence: true
validates :participants, presence: true
validates :recorded_at, presence: true
scope :with_provider, ->(current_provider) { where(user: { provider: current_provider }) }
......
......@@ -30,8 +30,13 @@ class RecordingCreator
new_name = @recording[:metadata][:name] || @recording[:name]
new_recording = Recording.find_or_create_by(room_id:, name: new_name, record_id: @recording[:recordID], visibility:,
participants: @recording[:participants], length:, protectable: @recording[:protected].present?)
new_recording = Recording.find_or_create_by(room_id:,
name: new_name,
record_id: @recording[:recordID],
visibility:,
participants: @recording[:participants],
length:, protectable: @recording[:protected].present?,
recorded_at: @recording[:startTime])
# Create format(s)
create_formats(recording: @recording, new_recording:)
......
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below).
#
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# Greenlight is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with Greenlight; if not, see <http://www.gnu.org/licenses/>.
# frozen_string_literal: true
class PopulateRecordedAtRecording < ActiveRecord::Migration[7.0]
def up
# rubocop:disable Rails/SkipsModelValidations
Recording.update_all('recorded_at = created_at')
# rubocop:enable Rails/SkipsModelValidations
end
def down
raise ActiveRecord::IrreversibleMigration
end
end
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below).
#
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# Greenlight is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with Greenlight; if not, see <http://www.gnu.org/licenses/>.
DataMigrate::Data.define(version: 20230123174546)
DataMigrate::Data.define(version: 20230228193705)
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below).
#
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# Greenlight is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with Greenlight; if not, see <http://www.gnu.org/licenses/>.
# frozen_string_literal: true
class AddRecordedAtToRecordings < ActiveRecord::Migration[7.0]
def change
add_column :recordings, :recorded_at, :datetime
end
end
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
#
# Copyright (c) 2022 BigBlueButton Inc. and by respective authors (see below).
#
# This program is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 3.0 of the License, or (at your option) any later
# version.
#
# Greenlight is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with Greenlight; if not, see <http://www.gnu.org/licenses/>.
# 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.
......@@ -26,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_10_25_184305) do
ActiveRecord::Schema[7.0].define(version: 2023_02_27_213252) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
......@@ -105,6 +89,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_25_184305) do
t.integer "length", null: false
t.integer "participants", null: false
t.boolean "protectable"
t.datetime "recorded_at"
t.index ["room_id"], name: "index_recordings_on_room_id"
end
......
......@@ -24,6 +24,7 @@ FactoryBot.define do
visibility { 'Unpublished' }
length { Faker::Number.within(range: 1..60) }
participants { Faker::Number.within(range: 1..100) }
recorded_at { Faker::Time.between(from: 2.days.ago, to: Time.zone.now) }
after(:create) do |recording|
create(:format, recording:)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment