mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-07 02:31:32 +00:00
Changing published to saved for person_saved_combined.
This commit is contained in:
parent
918c5e820d
commit
2244fd005d
5 changed files with 9 additions and 9 deletions
|
@ -731,12 +731,12 @@ BEGIN
|
||||||
AND p.thing_id = OLD.thing_id;
|
AND p.thing_id = OLD.thing_id;
|
||||||
ELSIF (TG_OP = 'INSERT') THEN
|
ELSIF (TG_OP = 'INSERT') THEN
|
||||||
IF NEW.saved IS NOT NULL THEN
|
IF NEW.saved IS NOT NULL THEN
|
||||||
INSERT INTO person_saved_combined (published, person_id, thing_id)
|
INSERT INTO person_saved_combined (saved, person_id, thing_id)
|
||||||
VALUES (NEW.saved, NEW.person_id, NEW.thing_id);
|
VALUES (NEW.saved, NEW.person_id, NEW.thing_id);
|
||||||
END IF;
|
END IF;
|
||||||
ELSIF (TG_OP = 'UPDATE') THEN
|
ELSIF (TG_OP = 'UPDATE') THEN
|
||||||
IF NEW.saved IS NOT NULL THEN
|
IF NEW.saved IS NOT NULL THEN
|
||||||
INSERT INTO person_saved_combined (published, person_id, thing_id)
|
INSERT INTO person_saved_combined (saved, person_id, thing_id)
|
||||||
VALUES (NEW.saved, NEW.person_id, NEW.thing_id);
|
VALUES (NEW.saved, NEW.person_id, NEW.thing_id);
|
||||||
-- If saved gets set as null, delete the row
|
-- If saved gets set as null, delete the row
|
||||||
ELSE
|
ELSE
|
||||||
|
|
|
@ -751,7 +751,7 @@ diesel::table! {
|
||||||
diesel::table! {
|
diesel::table! {
|
||||||
person_saved_combined (id) {
|
person_saved_combined (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
published -> Timestamptz,
|
saved -> Timestamptz,
|
||||||
person_id -> Int4,
|
person_id -> Int4,
|
||||||
post_id -> Nullable<Int4>,
|
post_id -> Nullable<Int4>,
|
||||||
comment_id -> Nullable<Int4>,
|
comment_id -> Nullable<Int4>,
|
||||||
|
|
|
@ -16,7 +16,7 @@ use i_love_jesus::CursorKeysModule;
|
||||||
/// A combined person_saved table.
|
/// A combined person_saved table.
|
||||||
pub struct PersonSavedCombined {
|
pub struct PersonSavedCombined {
|
||||||
pub id: PersonSavedCombinedId,
|
pub id: PersonSavedCombinedId,
|
||||||
pub published: DateTime<Utc>,
|
pub saved: DateTime<Utc>,
|
||||||
pub person_id: PersonId,
|
pub person_id: PersonId,
|
||||||
pub post_id: Option<PostId>,
|
pub post_id: Option<PostId>,
|
||||||
pub comment_id: Option<CommentId>,
|
pub comment_id: Option<CommentId>,
|
||||||
|
|
|
@ -220,9 +220,9 @@ impl PersonSavedCombinedQuery {
|
||||||
query = query.after(page_after);
|
query = query.after(page_after);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sorting by published
|
// Sorting by saved desc
|
||||||
query = query
|
query = query
|
||||||
.then_desc(key::published)
|
.then_desc(key::saved)
|
||||||
// Tie breaker
|
// Tie breaker
|
||||||
.then_desc(key::id);
|
.then_desc(key::id);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ FROM
|
||||||
-- This one is special, because you use the saved date, not the ordinary published
|
-- This one is special, because you use the saved date, not the ordinary published
|
||||||
CREATE TABLE person_saved_combined (
|
CREATE TABLE person_saved_combined (
|
||||||
id serial PRIMARY KEY,
|
id serial PRIMARY KEY,
|
||||||
published timestamptz NOT NULL,
|
saved timestamptz NOT NULL,
|
||||||
person_id int NOT NULL REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE,
|
person_id int NOT NULL REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
post_id int UNIQUE REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE,
|
post_id int UNIQUE REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
comment_id int UNIQUE REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE,
|
comment_id int UNIQUE REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE,
|
||||||
|
@ -39,12 +39,12 @@ CREATE TABLE person_saved_combined (
|
||||||
CHECK (num_nonnulls (post_id, comment_id) = 1)
|
CHECK (num_nonnulls (post_id, comment_id) = 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX idx_person_saved_combined_published ON person_saved_combined (published DESC, id DESC);
|
CREATE INDEX idx_person_saved_combined_published ON person_saved_combined (saved DESC, id DESC);
|
||||||
|
|
||||||
CREATE INDEX idx_person_saved_combined ON person_saved_combined (person_id);
|
CREATE INDEX idx_person_saved_combined ON person_saved_combined (person_id);
|
||||||
|
|
||||||
-- Updating the history
|
-- Updating the history
|
||||||
INSERT INTO person_saved_combined (published, person_id, post_id, comment_id)
|
INSERT INTO person_saved_combined (saved, person_id, post_id, comment_id)
|
||||||
SELECT
|
SELECT
|
||||||
saved,
|
saved,
|
||||||
person_id,
|
person_id,
|
||||||
|
|
Loading…
Reference in a new issue