Skip to content

Commit

Permalink
Merge pull request #40 from overhangio/redwood
Browse files Browse the repository at this point in the history
Feat: Upgrade to redwood
  • Loading branch information
regisb committed Jun 20, 2024
2 parents 1bca9ad + 90a519c commit 0066855
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 24 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ instructions, because git commits are used to generate release notes:

<!-- scriv-insert-here -->

<a id='changelog-18.0.0'></a>
## v18.0.0 (2024-06-20)

- 💥[Feature] Upgrade to Redwood. (by @Fahadkhalid210)
- [Bugfix] Make plugin compatible with Python 3.12 by removing dependency on `pkg_resources`. (by @regisb)
- [Improvement] Update User Activity dataset query by extending time span to 120 seconds and selecting all events where course ID is not null to improve average time spent in course. (by @Fahadkhalid210)
- [Improvement] Added CORS for embedded Dashboards. (by @Fahadkhalid210)
- 💥[Feature] Upgrade Clickhouse to version 24.1.8.22 and fix query issues due to deprecation of live views. (by @Fahadkhalid210)

<a id='changelog-17.1.0'></a>
## v17.1.0 (2024-02-09)

Expand Down
1 change: 0 additions & 1 deletion changelog.d/20240212_115536_regis_pkg_resources.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/20240405_151230_fahad.khalid.md

This file was deleted.

4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def load_about():
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
python_requires=">=3.8",
install_requires=["tutor>=17.0.0,<18.0.0"],
extras_require={"dev": ["tutor[dev]>=17.0.0,<18.0.0"]},
install_requires=["tutor>=18.0.0,<19.0.0"],
extras_require={"dev": ["tutor[dev]>=18.0.0,<19.0.0"]},
entry_points={"tutor.plugin.v1": ["cairn = tutorcairn.plugin"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
2 changes: 1 addition & 1 deletion tutorcairn/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "17.1.0"
__version__ = "18.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RENAME TABLE _openedx_course_enrollments TO openedx_course_enrollments;
RENAME TABLE _openedx_user_profiles TO openedx_user_profiles;
RENAME TABLE _openedx_users TO openedx_users;

DROP TABLE course_enrollments;
CREATE VIEW course_enrollments AS
SELECT
openedx_course_enrollments.course_id AS course_id,
openedx_course_enrollments.created AS enrollment_created,
openedx_course_enrollments.is_active AS enrollment_is_active,
openedx_course_enrollments.mode AS enrollment_mode,
openedx_course_enrollments.user_id AS user_id,
openedx_users.username AS username,
openedx_users.email AS user_email,
openedx_user_profiles.year_of_birth AS user_year_of_birth,
openedx_user_profiles.gender AS user_gender,
openedx_user_profiles.level_of_education AS user_level_of_education,
openedx_user_profiles.city AS user_city,
openedx_user_profiles.state AS user_state,
openedx_user_profiles.country AS user_country
FROM openedx_course_enrollments
INNER JOIN openedx_user_profiles ON openedx_course_enrollments.user_id = openedx_user_profiles.user_id
INNER JOIN openedx_users ON openedx_course_enrollments.user_id = openedx_users.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
RENAME TABLE _openedx_block_completion TO openedx_block_completion;

DROP TABLE course_block_completion;

CREATE VIEW course_block_completion AS
SELECT
openedx_block_completion.course_key AS course_id,
openedx_block_completion.block_key AS block_key,
openedx_block_completion.user_id AS user_id,
openedx_block_completion.completion AS completion,
course_blocks.position as position,
course_blocks.display_name as display_name,
course_blocks.full_name as full_name
FROM openedx_block_completion
INNER JOIN course_blocks ON openedx_block_completion.block_key = course_blocks.block_key;
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"ru": {"flag": "ru", "name": "Russian"},
"sk": {"flag": "sk", "name": "Slovak"},
"sl": {"flag": "si", "name": "Slovenian"},
"uk": {"flag": "uk", "name": "Ukranian"},
"zh": {"flag": "cn", "name": "Chinese"},
}
{#- https://github.com/apache/superset/blob/master/docs/docs/contributing/translations.mdx#enabling-language-selection #}
Expand Down
9 changes: 2 additions & 7 deletions tutorcairn/templates/cairn/build/cairn-clickhouse/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# https://hub.docker.com/r/yandex/clickhouse-server/tags
FROM docker.io/yandex/clickhouse-server:22.1.3.7
# https://hub.docker.com/r/clickhouse/clickhouse-server/tags
FROM docker.io/clickhouse/clickhouse-server:24.1.8.22

# The clickhouse repo is currently unavailable in some parts of the world. If we don't
# remove this repo here then `apt update` will fail. Check if the problem is resolved with:
# curl https://repo.yandex.ru/clickhouse/deb/stable/
# The above command should be a 200, and not a 404.
RUN rm /etc/apt/sources.list.d/clickhouse.list
RUN apt update && apt install -y python3
COPY ./scripts /scripts
RUN chmod a+x /scripts/*
Expand Down
10 changes: 5 additions & 5 deletions tutorcairn/templates/cairn/build/cairn-superset/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://github.com/apache/superset/releases
# https://github.com/apache/superset/blob/master/Dockerfile
# https://superset.apache.org/docs/databases/installing-database-drivers
FROM docker.io/apache/superset:3.0.1
FROM docker.io/apache/superset:4.0.0

USER root

Expand All @@ -18,11 +18,11 @@ RUN apt-get update \
pkg-config

RUN --mount=type=cache,target=/root/.cache/pip,sharing=shared pip install \
clickhouse-driver==0.2.6 \
mysqlclient==2.2.0 \
clickhouse-connect==0.6.20 \
clickhouse-driver==0.2.7 \
mysqlclient==2.2.4 \
clickhouse-connect==0.7.8 \
clickhouse-sqlalchemy==0.2.4 \
authlib==1.2.1
authlib==1.3.0

USER superset

Expand Down
19 changes: 13 additions & 6 deletions tutorcairn/templates/cairn/build/cairn-superset/cairn/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def check_permission(permission_view) -> bool:
return False

# Create or update role with the same name as the user
security_manager.set_role(role_name, check_permission)
pvms = security_manager._get_all_pvms()
security_manager.set_role(role_name, check_permission, pvms)


def create_clickhouse_user(clickhouse_username):
Expand Down Expand Up @@ -117,11 +118,17 @@ def grant_clickhouse_row_based_access(clickhouse_username, course_ids=None):
for table in make_clickhouse_query("SHOW TABLES").split("\n"):
if not table.startswith("_"):
make_clickhouse_query(
f"""GRANT SELECT ON {table} TO '{clickhouse_username}';"""
)
make_clickhouse_query(
f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING {condition} TO '{clickhouse_username}';"""
)
f"""GRANT SELECT ON {table} TO '{clickhouse_username}';"""
)

if table in ["openedx_users", "openedx_user_profiles", "openedx_block_completion"]:
make_clickhouse_query(
f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING 1 TO '{clickhouse_username}';"""
)
else:
make_clickhouse_query(
f"""CREATE ROW POLICY OR REPLACE '{clickhouse_username}' ON {table} AS RESTRICTIVE FOR SELECT USING {condition} TO '{clickhouse_username}';"""
)


def make_clickhouse_query(query):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from superset.models.core import Database
from superset.models.slice import Slice
from superset.extensions import db, security_manager
import superset.dashboards.commands.importers.v0 as importers
import superset.commands.dashboard.importers.v0 as importers
from werkzeug.security import generate_password_hash

# Our convenient library
Expand Down

0 comments on commit 0066855

Please sign in to comment.