-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from seart-group/enhancement/autocomplete
- Loading branch information
Showing
57 changed files
with
1,072 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="GitRepoController | GET /r/languages" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" index="4" requestIdentifier="GET /r/languages" runType="Run single request"> | ||
<configuration default="false" name="GitRepoController | GET /r/languages" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" index="5" requestIdentifier="GET /r/languages" runType="Run single request"> | ||
<method v="2" /> | ||
</configuration> | ||
</component> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="GitRepoController | GET /r/licenses" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" index="6" requestIdentifier="GET /r/licenses" runType="Run single request"> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="GitRepoController | GET /r/topics" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" index="5" requestIdentifier="GET /r/topics" runType="Run single request"> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="GitRepoController | GET /r/{owner}/{name}" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" index="2" requestIdentifier="GET /r/{owner}/{name}" runType="Run single request"> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
DROP TABLE IF EXISTS label_ranked; | ||
|
||
CREATE OR REPLACE VIEW count_git_repo_by_label AS | ||
SELECT | ||
label.id AS label_id, | ||
COUNT(repo_id) AS count | ||
FROM label | ||
LEFT JOIN git_repo_label | ||
ON git_repo_label.label_id = label.id | ||
GROUP BY label.id; | ||
|
||
CREATE TABLE label_statistics ( | ||
label_id BIGINT NOT NULL | ||
PRIMARY KEY, | ||
count BIGINT NOT NULL | ||
) | ||
SELECT * FROM count_git_repo_by_label; | ||
|
||
CREATE INDEX count_idx ON label_statistics (count); | ||
|
||
CREATE TRIGGER label_insert | ||
AFTER INSERT ON label | ||
FOR EACH ROW | ||
BEGIN | ||
INSERT INTO label_statistics (label_id, count) | ||
VALUES (NEW.id, 0); | ||
END; | ||
|
||
CREATE TRIGGER label_delete | ||
AFTER DELETE ON label | ||
FOR EACH ROW | ||
BEGIN | ||
DELETE FROM label_statistics | ||
WHERE label_id = OLD.id; | ||
END; | ||
|
||
CREATE TRIGGER git_repo_label_insert | ||
AFTER INSERT ON git_repo_label | ||
FOR EACH ROW | ||
BEGIN | ||
UPDATE label_statistics | ||
SET count = count + 1 | ||
WHERE label_id = NEW.label_id; | ||
END; | ||
|
||
CREATE TRIGGER git_repo_label_delete | ||
AFTER DELETE ON git_repo_label | ||
FOR EACH ROW | ||
BEGIN | ||
UPDATE label_statistics | ||
SET count = count - 1 | ||
WHERE label_id = OLD.label_id; | ||
END; | ||
|
||
CREATE TRIGGER git_repo_label_update | ||
AFTER UPDATE ON git_repo_label | ||
FOR EACH ROW | ||
BEGIN | ||
UPDATE label_statistics | ||
SET count = count + 1 | ||
WHERE label_id = NEW.label_id; | ||
UPDATE label_statistics | ||
SET count = count - 1 | ||
WHERE label_id = OLD.label_id; | ||
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
DROP TABLE IF EXISTS topic_ranked; | ||
|
||
CREATE OR REPLACE VIEW count_git_repo_by_topic AS | ||
SELECT | ||
topic.id AS topic_id, | ||
COUNT(repo_id) AS count | ||
FROM topic | ||
LEFT JOIN git_repo_topic | ||
ON topic.id = git_repo_topic.topic_id | ||
GROUP BY topic.id; | ||
|
||
CREATE TABLE topic_statistics ( | ||
topic_id BIGINT NOT NULL | ||
PRIMARY KEY, | ||
count BIGINT NOT NULL | ||
) | ||
SELECT * FROM count_git_repo_by_topic; | ||
|
||
CREATE INDEX count_idx ON topic_statistics (count); | ||
|
||
CREATE TRIGGER topic_insert | ||
AFTER INSERT ON topic | ||
FOR EACH ROW | ||
BEGIN | ||
INSERT INTO topic_statistics (topic_id, count) | ||
VALUES (NEW.id, 0); | ||
END; | ||
|
||
CREATE TRIGGER topic_delete | ||
AFTER DELETE ON topic | ||
FOR EACH ROW | ||
BEGIN | ||
DELETE FROM topic_statistics | ||
WHERE topic_id = OLD.id; | ||
END; | ||
|
||
CREATE TRIGGER git_repo_topic_insert | ||
AFTER INSERT ON git_repo_topic | ||
FOR EACH ROW | ||
BEGIN | ||
UPDATE topic_statistics | ||
SET count = count + 1 | ||
WHERE topic_id = NEW.topic_id; | ||
END; | ||
|
||
CREATE TRIGGER git_repo_topic_delete | ||
AFTER DELETE ON git_repo_topic | ||
FOR EACH ROW | ||
BEGIN | ||
UPDATE topic_statistics | ||
SET count = count - 1 | ||
WHERE topic_id = OLD.topic_id; | ||
END; | ||
|
||
CREATE TRIGGER git_repo_topic_update | ||
AFTER UPDATE ON git_repo_topic | ||
FOR EACH ROW | ||
BEGIN | ||
UPDATE topic_statistics | ||
SET count = count + 1 | ||
WHERE topic_id = NEW.topic_id; | ||
UPDATE topic_statistics | ||
SET count = count - 1 | ||
WHERE topic_id = OLD.topic_id; | ||
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE event_log ( | ||
name VARCHAR(255) NOT NULL, | ||
start TIMESTAMP NOT NULL, | ||
end TIMESTAMP NOT NULL, | ||
CONSTRAINT unique_composite_key | ||
UNIQUE (name, start) | ||
); | ||
|
||
ALTER TABLE event_log ADD CHECK (start <= end); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
CREATE OR REPLACE VIEW count_git_repo_by_license AS | ||
SELECT | ||
license_id AS license_id, | ||
COUNT(id) AS count | ||
FROM git_repo | ||
WHERE license_id IS NOT NULL | ||
GROUP BY license_id | ||
ORDER BY count DESC; | ||
|
||
CREATE TABLE license_statistics ( | ||
license_id BIGINT NOT NULL | ||
PRIMARY KEY, | ||
count BIGINT NOT NULL | ||
) | ||
SELECT * FROM count_git_repo_by_license; | ||
|
||
CREATE INDEX count_idx ON license_statistics (count); | ||
|
||
CREATE PROCEDURE license_statistics_refresh() | ||
BEGIN | ||
DECLARE _start TIMESTAMP; | ||
DECLARE _end TIMESTAMP; | ||
|
||
SET _start = NOW(); | ||
|
||
START TRANSACTION; | ||
REPLACE INTO license_statistics | ||
SELECT * FROM count_git_repo_by_license; | ||
COMMIT; | ||
|
||
SET _end = NOW(); | ||
|
||
INSERT INTO event_log (name, start, end) | ||
VALUE ('license_statistics_refresh', _start, _end); | ||
END; | ||
|
||
CREATE EVENT license_statistics_refresh | ||
ON SCHEDULE | ||
EVERY 1 HOUR | ||
STARTS CURRENT_TIMESTAMP | ||
+ INTERVAL 1 HOUR | ||
- INTERVAL MINUTE(CURRENT_TIMESTAMP) MINUTE | ||
- INTERVAL SECOND(CURRENT_TIMESTAMP) SECOND | ||
- INTERVAL MICROSECOND(CURRENT_TIMESTAMP) MICROSECOND | ||
DO CALL license_statistics_refresh(); |
Oops, something went wrong.