Hello,
Recently my forum had an extended 2 day downtime because of issues with our domain.
That caused everybody’s visit streaks to break, which is very bad to most people.
I’m looking to restore these, how can I?
Hello,
Recently my forum had an extended 2 day downtime because of issues with our domain.
That caused everybody’s visit streaks to break, which is very bad to most people.
I’m looking to restore these, how can I?
You’d need to contrive to add data to the tables to make it look like everyone visited on those days. You’d need to read the source, figure out which tables need to add rows to, and then create records on them for each user.
If you don’t know how to do that and do not get a response quickly enough, you can post a budget in marketplace.
They need to get their priorities straight
Anyway, to copy visits from one day to another you need to run this SQL query
insert into user_visits
select 0, user_id, '2022-09-09', posts_read, mobile, 0
from user_visits
where visited_at = '2022-09-08'
;
where the first date is the date you want to fake and the second date is where you want to copy from.
Richard saves the day again! What a great solution. I was wondering how to do it without just giving everyone credit. Brilliant!
You would be shocked the amount of people that complained about it
Thanks for the script, where can I run it?
cd /var/discourse
./launcher enter app
rails c
DB.exec("insert into user_visits select 0, user_id, '2022-09-09', posts_read, mobile, 0 from user_visits where visited_at = '2022-09-08'")
Hey, we had another outage, and when I went to restore the visits again, we had an error.
[6] pry(main)> DB.exec("insert into user_visits select 4, user_id, '2022-12-31', posts_read, mobile, 0 from user_visits where visited_at = '2022-09-01'")
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "user_visits_pkey"
DETAIL: Key (id)=(4) already exists.
from /var/www/discourse/vendor/bundle/ruby/3.1.0/gems/rack-mini-profiler-3.0.0/lib/patches/db/pg.rb:110:in `exec'