Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not query user's page views #2415

Open
kenxt opened this issue Oct 1, 2024 · 2 comments
Open

Could not query user's page views #2415

kenxt opened this issue Oct 1, 2024 · 2 comments

Comments

@kenxt
Copy link

kenxt commented Oct 1, 2024

Summary:

I have a self-hosted canvas(prod 2024/09/23), and configed a cassandra, copyed analytics. I found the file cassandra.yml has gone, so I created a cassandra.yml, and executed "rake db:migrate" again, the system created tables in cassandra. But I could not query any user's pageviews , and the table page_views is empty in cassandra. I can access "views courses analytics", and canvas display course related data information on the page.

Steps to reproduce:

1.git analytics
2.rake db:migrate successfuly, Setting.set('enable_page_views', 'cassandra')
3.fail to rake db:migrate_pageviews_to_cassandra.
rake aborted!
Don't know how to build task 'db:migrate_pageviews_to_cassandra' (See the list of available tasks with

Expected behavior:

canvas can display course related data information in analytics pages.
administrator can query page view history.

Actual behavior:

the page view history is empty

Additional notes:

I have not found db:migrate_pageviews_to_cassandra in the list of available tasks with rake --tasks
I found some explanatory text in gems/canvas_cassandra, I'm not sure if there are more detailed explanations or guidance documents available

@kenxt
Copy link
Author

kenxt commented Oct 2, 2024

I think I have found the answer.
I have reviewed the code content of models/page-view.rb#self.page-viewed_method:
def self.page_view_method
enable_page_views = Setting.get("enable_page_views", "false")
return false if enable_page_views == "false"
enable_page_views = "db" if %w[true cache].include?(enable_page_views) # backwards compat
enable_page_views.to_sym
end
I found that the code only determined whether enable_mage-views was enabled (based on https://github.com/instructure/canvas-lms/wiki/Settings-%28customization%29,the default value is false)
When configured as true or cache, the content of the pageviews will be written to the postgres table page_views.
So I Executed:
Setting.set('enable_page_views', 'true') or Setting.set('enable_page_views', 'db')
After restarting the Canvas service, it was found that access records could be displayed.
When I executed the log query statement:
tail - f production. log | grep page-views
I found the written SQL:
INSERT INTO "public"."page_views" ("request_id", "session_id", "user_id", "url", "controller", "action", "interaction_seconds", "created_at", "updated_at", "user_request", "render_time", "user_agent", "summarized", "account_id", "http_method", "remote_ip") VALUES ('......

So the new version of Canvas has changed the mechanism for saving pageviews, which is partially explained in gems/canvas_cassandra/Readme. It's just that the document doesn't clearly describe the changes in parameters, and I don't know if the Canvas system still supports writing pageviews to cassandra, or I haven't read it myself.

@kenxt
Copy link
Author

kenxt commented Oct 2, 2024

The current canvas version does not support
writing page views to cassandra. dB/migrate/20240604155656_migrate_cassandra_data_to_postgres.rb is used to copy data from cassandra to postgres and set enable_page_view to db.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant