Skip to content

Commit

Permalink
Merge pull request #341 from seart-group/enhancement/autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
dabico authored Apr 12, 2024
2 parents 1c2a6d3 + 7fff156 commit 6b59c52
Show file tree
Hide file tree
Showing 57 changed files with 1,072 additions and 391 deletions.
2 changes: 1 addition & 1 deletion .run/http/GitRepoController _ GET _r_labels.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<configuration default="false" name="GitRepoController | GET /r/labels" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" index="3" requestIdentifier="GET /r/labels" runType="Run single request">
<method v="2" />
</configuration>
</component>
</component>
4 changes: 2 additions & 2 deletions .run/http/GitRepoController _ GET _r_languages.run.xml
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>
5 changes: 5 additions & 0 deletions .run/http/GitRepoController _ GET _r_licenses.run.xml
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>
2 changes: 1 addition & 1 deletion .run/http/GitRepoController _ GET _r_search.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<configuration default="false" name="GitRepoController | GET /r/search" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" index="2" requestIdentifier="GET /r/search" runType="Run single request">
<method v="2" />
</configuration>
</component>
</component>
2 changes: 1 addition & 1 deletion .run/http/GitRepoController _ GET _r_stats.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<configuration default="false" name="GitRepoController | GET /r/stats" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" index="6" requestIdentifier="GET /r/stats" runType="Run single request">
<method v="2" />
</configuration>
</component>
</component>
5 changes: 5 additions & 0 deletions .run/http/GitRepoController _ GET _r_topics.run.xml
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>
2 changes: 1 addition & 1 deletion .run/http/GitRepoController _ GET _r_{id}.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<configuration default="false" name="GitRepoController | GET /r/{id}" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" path="$PROJECT_DIR$/http/GitRepoController.http" requestIdentifier="GET /r/{id}" runType="Run single request">
<method v="2" />
</configuration>
</component>
</component>
5 changes: 5 additions & 0 deletions .run/http/GitRepoController _ GET _r_{owner}_{name}.run.xml
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>
2 changes: 1 addition & 1 deletion .run/http/LanguageController _ GET _l.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<configuration default="false" name="LanguageController | GET /l" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" environment="dev" path="$PROJECT_DIR$/http/LanguageController.http" requestIdentifier="GET /l" runType="Run single request">
<method v="2" />
</configuration>
</component>
</component>
2 changes: 1 addition & 1 deletion .run/http/RootController _ GET _.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<configuration default="false" name="RootController | GET /" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" environment="dev" path="$PROJECT_DIR$/http/RootController.http" requestIdentifier="GET /" runType="Run single request">
<method v="2" />
</configuration>
</component>
</component>
2 changes: 1 addition & 1 deletion .run/http/RootController _ GET _version.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<configuration default="false" name="RootController | GET /version" type="HttpClient.HttpRequestRunConfigurationType" factoryName="HTTP Request" nameIsGenerated="true" environment="dev" path="$PROJECT_DIR$/http/RootController.http" index="2" requestIdentifier="GET /version" runType="Run single request">
<method v="2" />
</configuration>
</component>
</component>
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ Here's a list of project-specific arguments supported by the application that yo
| `ghs.analysis.max-pool-threads` | int | 3 | Maximum amount of live threads dedicated to concurrently analyzing repositories. Must be positive. |
| `ghs.clean-up.enabled` | Boolean | true | Specifies if the job responsible for removing unavailable repositories (clean-up) is enabled. |
| `ghs.clean-up.cron` | CronTrigger | 0 0 0 \* \* 1 | Delay between successive repository clean-up runs, expressed as a [Spring CRON expression](https://spring.io/blog/2020/11/10/new-in-spring-5-3-improved-cron-expressions). |
| `ghs.statistics.suggestion-limit` | int | 500 | Maximum number of suggestions available in UI autocompletion. Must not be negative. To disable the limit use 0. |

### Web UI

Expand Down
8 changes: 4 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const js = require("@eslint/js");
const globals = require("globals");
import js from "@eslint/js";
import globals from "globals";

module.exports = [
export default [
js.configs.recommended,
{
files: ["**/*.js"],
languageOptions: {
sourceType: "commonjs",
sourceType: "module",
ecmaVersion: 2024,
globals: {
...globals.node,
Expand Down
66 changes: 0 additions & 66 deletions flyway/sql/R__materialized_views.sql

This file was deleted.

65 changes: 65 additions & 0 deletions flyway/sql/V15__label.sql
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;
65 changes: 65 additions & 0 deletions flyway/sql/V16__topic.sql
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;
11 changes: 11 additions & 0 deletions flyway/sql/V17__event.sql
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);


45 changes: 45 additions & 0 deletions flyway/sql/V18__license.sql
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();
Loading

0 comments on commit 6b59c52

Please sign in to comment.