Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search form autocompletion #341

Merged
merged 56 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a982a16
Change project JavaScript source type to `module`
dabico Apr 10, 2024
6dec1e7
Use new autocomplete for `language` and `license` fields
dabico Apr 10, 2024
327e0ba
Create new migration for a `label_statistics` "materialized view" table
dabico Apr 10, 2024
d32d780
Remove `label_ranked` relation and `LabelView` entity
dabico Apr 10, 2024
4a97713
Rename `NamedEntityService` service method
dabico Apr 10, 2024
422aca7
Map new `label_statistics` relation to `Label.Statistics` inner class
dabico Apr 10, 2024
9448137
Add dedicated repository for new `Label.Statistics` entity
dabico Apr 10, 2024
2b82f69
Overhaul of `/r/labels` endpoint
dabico Apr 10, 2024
8dbe027
Update HTTP run configurations to allow for better testing
dabico Apr 10, 2024
ec38a4d
Add a longer description for the changed endpoint
dabico Apr 10, 2024
84e7df0
Add hard-coded metamodel definition for `Label.Statistics`
dabico Apr 10, 2024
6cdc869
Small fix in OpenAPI endpoint documentation
dabico Apr 10, 2024
d60dd2e
Create new migration for a `topic_statistics` "materialized view" table
dabico Apr 10, 2024
9e0f89f
Remove `topic_ranked` relation and `TopicView` entity
dabico Apr 10, 2024
7df7bb2
Map new `topic_statistics` relation to `Topic.Statistics` inner class
dabico Apr 10, 2024
e4f2dbf
Add hard-coded metamodel definition for `Topic.Statistics`
dabico Apr 10, 2024
8c4fc1e
Add dedicated repository for new `Topic.Statistics` entity
dabico Apr 10, 2024
c6b7adc
Overhaul of `/r/topics` endpoint
dabico Apr 10, 2024
c266a24
Small fix in OpenAPI endpoint documentation
dabico Apr 10, 2024
09d7227
Update HTTP run configurations
dabico Apr 11, 2024
d708092
Add result pagination to all the repository-information endpoints
dabico Apr 11, 2024
c6837d3
Make sure all licenses are retrieved from paginated endpoint
dabico Apr 11, 2024
5d361d5
Rename language.js to autocomplete.js
dabico Apr 11, 2024
a3e01eb
Update intermediate view names for `License` and `Topic`
dabico Apr 11, 2024
22181b8
Create new migration for a `license_statistics` view
dabico Apr 11, 2024
94d91db
Map new `license_statistics` view to `License.Statistics` inner class
dabico Apr 11, 2024
0febec6
Add hard-coded metamodel definition for `License.Statistics`
dabico Apr 11, 2024
21132b2
Add dedicated repository for new `License.Statistics` entity
dabico Apr 11, 2024
94acbc1
Materialize `license_statistics` on server startup
dabico Apr 11, 2024
0280e1f
Overhaul of `/r/licenses` endpoint
dabico Apr 11, 2024
46a9d3e
Update HTTP run configurations
dabico Apr 11, 2024
91c644b
Add relation for storing the name and start/end `timestamp` of events
dabico Apr 11, 2024
3a9c574
Create hourly event for refreshing license statistics
dabico Apr 11, 2024
0126457
Add missing HTTP endpoint for getting repository by full-name
dabico Apr 11, 2024
1dc2613
Add missing run configuration for `/r/topics`
dabico Apr 11, 2024
9259379
Overhaul of `/r/languages` endpoint
dabico Apr 11, 2024
ce435dc
Update HTTP run configurations to allow for better testing
dabico Apr 11, 2024
20a12da
Replace `TypedQuery` use with dedicated `Repository` interface methods
dabico Apr 11, 2024
861f1bd
Add custom Jackson serializer for `Sort` instances
dabico Apr 11, 2024
666b34f
Add custom Jackson serializer for `Page` instances
dabico Apr 11, 2024
d77db66
Create dedicated Jackson serialization module containing new serializers
dabico Apr 11, 2024
dfe25c3
Register new module in `JacksonConfig`
dabico Apr 11, 2024
abef2aa
Use custom serializers when returning search results
dabico Apr 11, 2024
35408e9
Properly paginate all endpoints related to `NamedEntityService`
dabico Apr 11, 2024
4d7df71
Fix: incorrect count query for a `LanguageRepository` method
dabico Apr 11, 2024
3722123
Rewrite query string to match style of other added queries
dabico Apr 11, 2024
a7614e3
Rewrite query strings in GitRepoRepository to match style
dabico Apr 11, 2024
dcaf936
Add hard-coded metamodel definition for `Language.Statistics`
dabico Apr 11, 2024
f975c58
Overhaul of `/l` endpoint
dabico Apr 11, 2024
5549f83
Add text underline highlighting to autocomplete matches
dabico Apr 12, 2024
b214b7b
Replace `typeahead` with the superior `autocomplete`
dabico Apr 12, 2024
e69ae90
Improve Swagger documentation for `Pageable` route parameters
dabico Apr 12, 2024
102d135
Fix: view counts for many-to-many relationships
dabico Apr 12, 2024
002e28d
Remove unused bean definition
dabico Apr 12, 2024
026a43e
Remove obsolete configuration property
dabico Apr 12, 2024
7fff156
Update README.md
dabico Apr 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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