Currently, Topics are managed via the Rails Console and some Rake tasks. Below are steps for setting up a new Topic and preparing data for analysis. If not running locally, the following assumes you have SSH access to the server and your public SSH key is appropriately installed on the server.
rails console
from project directory.cap rails:console
.cd /var/www/impact-visualizer/current
RAILS_ENV=production bundle exec rails console
Topic.create(
name: 'Topic Name',
slug: 'topic_name',
description: 'Brief description of topic',
editor_label: 'participant',
start_date: Date.new(2022, 1, 1),
end_date: Date.new(2022, 12, 31),
timepoint_day_interval: 365,
wiki_id: 1,
display: true
)
name
: The topic's name. Spaces OK. Should be title cased. slug
: A URL-safe version of the Topic's name. description
: A description of the Topic and participant group.editor_label
: A lowercase word to describe the users whose activity will be visualized. "participant" is the default.start_date
: a Ruby Date object representing the start of the analysis period.end_date
: a Ruby Date object representing the end of the analysis period.timepoint_day_interval
: the number of days between analysis timepoints (between the start and end dates). An interval of 30, for example, would roughly lead to monthly analysis snapshots. Typically, the longer the topic's timeframe, the higher this number should be (for both visualization and analysis speed reasons). wiki_id
: The ID of the associated Wiki version. Run Wiki.all
to see all available options.display
: a boolean switch to determine whether or not the Topic will be displayed on homepage of visualizer. Should be left as false
until topic's data is ready to be displayed.You can edit the topic in the Rails console like so:
topic = Topic.find_by(slug: 'topic_name')
topic.update(editor_label: 'editor')
Two CSV files are required for the importing of Topic data, one for Articles and another for Users. They should be prepared as follows. See csv/topic-articles-example.csv and csv/topic-users-example.csv for example files.
topic-articles-topic_slug.csv
where "topic_slug" is the Topic's slug.topic-users-topic_slug.csv
where "topic_slug" is the Topic's slug.With the CSV files in place, you can now run the import script.
rake import_topic topic_slug
where "topic_slug" is the Topic's slug.As this import script will fetch information about each Article and User it can take a long time. Given this, it is recommended that the script be run within a tool like tmux, which will allow you to disconnect from the server and leave the script running. You can log back in a later time to check progress or results.
tmux
to start a new tmux session OR tmux a
to attach to an existing tmux session. RAILS_ENV=production rake import_topic topic_slug
After you have both created a Topic via rails console
and imported associated articles and users via rake import_topic topic_slug
, you are now ready to "generate timepoints" which is the process of preparing and analyzing the data needed for visualization. To do this, there is another Rake task/script.
rake generate_timepoints topic_slug
where "topic_slug" is the Topic's slug.The note above about the usage of tmux also applies here, perhaps even more so, depending on the specifics of your Topic. Use tmux!
tmux
to start a new tmux session OR tmux a
to attach to an existing tmux session. RAILS_ENV=production rake generate_timepoints topic_slug
After the initial timepoint generation for a Topic has taken place, you may safely run the same generate_timepoints
script again to capture additional data (perhaps because the timeframe has changed or new articles have been added). Running the script again, as specified above, will generally NOT cause analysis of existing articles to take place again. Because of this, subsequent runs will be much faster.
If you would like to force existing analysis to be recomputed, you may force updates by adding "true" to the end of the command, such as this:
rake generate_timepoints topic_slug true
bundle install
yarn install
rake db:create
rake db:migrate
rails server
vite dev
(in a 2nd terminal window/pane)rspec
(tests are located in /spec directory)In the project's root directory, create a .env.local
file following the format of the .env.example
file
In the project's root directory, create a .env.production
file following the format of the .env.example
file
git push production
cap production deploy
In addition to deploying the latest code, the above deploy command will run any pending Rails migrations and will also compile front-end resources. To learn more about other, more granular, Capistrano commands see their documentation.
/var/www/impact-visualizer
cap production deploy
to deploy code