Skip to content

Commit

Permalink
Issue #91: Integrated META_UPDATE also into NUMBERS table.
Browse files Browse the repository at this point in the history
  • Loading branch information
haumacher committed Dec 1, 2024
1 parent cd2f534 commit 9db3cbe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ SELECT COUNT(1) cnt, CASE WHEN s.VOTES < #{minVotes} THEN 0 WHEN s.VOTES < 6 THE
@Update("update COMMENTS s set s.UP = s.UP + #{up}, s.DOWN = s.DOWN + #{down} where s.ID = #{id}")
int updateCommentVotes(String id, int up, int down);

@Select("select s.LASTUPDATE from META_UPDATE s where s.PHONE=#{phone}")
@Select("select s.LASTMETA from NUMBERS s where s.PHONE=#{phone}")
Long getLastMetaSearch(String phone);

@Update("update META_UPDATE s set s.LASTUPDATE=#{lastUpdate} where s.PHONE=#{phone}")
@Update("update NUMBERS s set s.LASTMETA=#{lastUpdate} where s.PHONE=#{phone}")
int setLastMetaSearch(String phone, long lastUpdate);

@Insert("insert into META_UPDATE (PHONE, LASTUPDATE) values (#{phone}, #{lastUpdate})")
void insertLastMetaSearch(String phone, long lastUpdate);
@Insert("insert into NUMBERS (PHONE, ADDED, LASTMETA) values (#{phone}, #{now}, #{now})")
void insertLastMetaSearch(String phone, long now);

@Select("SELECT PHONE FROM SUMMARY_REQUEST sr ORDER BY sr.PRIORITY LIMIT 1")
String topSummaryRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CREATE TABLE NUMBERS (
PHONE CHARACTER VARYING(100) NOT NULL,
ADDED BIGINT DEFAULT 0 NOT NULL,
UPDATED BIGINT DEFAULT 0 NOT NULL,
LASTMETA BIGINT DEFAULT 0 NOT NULL,
ACTIVE BOOLEAN DEFAULT TRUE NOT NULL,
CALLS INTEGER DEFAULT 0 NOT NULL,
VOTES INTEGER DEFAULT 0 NOT NULL,
Expand Down Expand Up @@ -238,6 +239,10 @@ SET VOTES = COALESCE (
);


-- Import META_UPDATE
UPDATE NUMBERS n SET LASTMETA = COALESCE( (SELECT u.LASTUPDATE FROM META_UPDATE u WHERE u.PHONE = n.PHONE), 0);


-- Complete revision ranges
-- Note: The rest is done in code, because it is too inefficient to do in SQL.
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CREATE TABLE NUMBERS (
PHONE CHARACTER VARYING(100) NOT NULL,
ADDED BIGINT DEFAULT 0 NOT NULL,
UPDATED BIGINT DEFAULT 0 NOT NULL,
LASTMETA BIGINT DEFAULT 0 NOT NULL,
ACTIVE BOOLEAN DEFAULT TRUE NOT NULL,
CALLS INTEGER DEFAULT 0 NOT NULL,
VOTES INTEGER DEFAULT 0 NOT NULL,
Expand Down Expand Up @@ -272,13 +273,6 @@ CREATE TABLE RATINGHISTORY (
CONSTRAINT RATINGHISTORY_PK PRIMARY KEY (REV,PHONE,RATING)
);

CREATE TABLE META_UPDATE (
PHONE CHARACTER VARYING(100) NOT NULL,
LASTUPDATE BIGINT NOT NULL,

CONSTRAINT META_UPDATE_PK PRIMARY KEY (PHONE)
);

CREATE TABLE COMMENTS (
ID VARCHAR(64) NOT NULL,

Expand Down

0 comments on commit 9db3cbe

Please sign in to comment.