Skip to content

Commit

Permalink
Remove most recent commit information and sorting (#2637)
Browse files Browse the repository at this point in the history
  • Loading branch information
charisk authored Jul 25, 2023
1 parent 8f99ed2 commit b87fe94
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 186 deletions.
1 change: 0 additions & 1 deletion docs/test-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ This requires running a MRVA query and seeing the results view.
1. Alphabetically
2. By number of results
3. By popularity
4. By most recent commit
9. Can filter repos
10. Shows correct statistics
1. Total number of results
Expand Down
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [UNRELEASED]

- Remove "last updated" information and sorting from variant analysis results view. [#2637](https://github.com/github/vscode-codeql/pull/2637)
- Links to code on GitHub now include column numbers as well as line numbers. [#2406](https://github.com/github/vscode-codeql/pull/2406)
- No longer highlight trailing commas for jump to definition. [#2615](https://github.com/github/vscode-codeql/pull/2615)

Expand Down
2 changes: 0 additions & 2 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,11 @@
"enum": [
"alphabetically",
"popularity",
"mostRecentCommit",
"numberOfResults"
],
"enumDescriptions": [
"Sort repositories alphabetically in the results view.",
"Sort repositories by popularity in the results view.",
"Sort repositories by most recent commit in the results view.",
"Sort repositories by number of results in the results view."
],
"description": "The default sorting order for repositories in the variant analysis results view."
Expand Down
20 changes: 0 additions & 20 deletions extensions/ql-vscode/src/stories/common/LastUpdated.stories.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Repository, RepositoryWithMetadata } from "./repository";
import { parseDate } from "../../common/date";
import { assertNever } from "../../common/helpers-pure";

export enum FilterKey {
Expand All @@ -10,7 +9,6 @@ export enum FilterKey {
export enum SortKey {
Alphabetically = "alphabetically",
Popularity = "popularity",
MostRecentCommit = "mostRecentCommit",
NumberOfResults = "numberOfResults",
}

Expand Down Expand Up @@ -81,16 +79,6 @@ export function compareRepository(
}
}

// Newest to oldest
if (filterSortState?.sortKey === SortKey.MostRecentCommit) {
const lastUpdated =
(parseDate(right.updatedAt)?.getTime() ?? 0) -
(parseDate(left.updatedAt)?.getTime() ?? 0);
if (lastUpdated !== 0) {
return lastUpdated;
}
}

// Fall back on name compare. Use en-US because the repository name does not contain
// special characters due to restrictions in GitHub owner/repository names.
return left.fullName.localeCompare(right.fullName, "en-US", {
Expand Down
42 changes: 0 additions & 42 deletions extensions/ql-vscode/src/view/common/LastUpdated.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions extensions/ql-vscode/src/view/variant-analysis/RepoRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import { vscode } from "../vscode-api";
import { AnalyzedRepoItemContent } from "./AnalyzedRepoItemContent";
import StarCount from "../common/StarCount";
import { LastUpdated } from "../common/LastUpdated";
import { useTelemetryOnChange } from "../common/telemetry";
import { DeterminateProgressRing } from "../common/DeterminateProgressRing";

Expand Down Expand Up @@ -297,7 +296,6 @@ export const RepoRow = ({
<div>
<StarCount starCount={repository.stargazersCount} />
</div>
<LastUpdated lastUpdated={repository.updatedAt} />
</MetadataContainer>
</TitleContainer>
{isExpanded && expandableContentLoaded && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ export const RepositoriesSort = ({ value, onChange, className }: Props) => {
Number of results
</VSCodeOption>
<VSCodeOption value={SortKey.Popularity}>Popularity</VSCodeOption>
<VSCodeOption value={SortKey.MostRecentCommit}>
Most recent commit
</VSCodeOption>
</Dropdown>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ describe(RepoRow.name, () => {
expect(
screen.queryByRole("img", {
// There should not be any icons, except for the icons which are always shown
name: (name) =>
!["expand", "stars count", "most recent commit"].includes(
name.toLowerCase(),
),
name: (name) => !["expand", "stars count"].includes(name.toLowerCase()),
}),
).not.toBeInTheDocument();

Expand Down Expand Up @@ -279,26 +276,7 @@ describe(RepoRow.name, () => {
).toBeInTheDocument();
});

it("shows updated at", () => {
render({
repository: {
...createMockRepositoryWithMetadata(),
// 1 month ago
updatedAt: new Date(
Date.now() - 1000 * 60 * 60 * 24 * 30,
).toISOString(),
},
});

expect(screen.getByText("last month")).toBeInTheDocument();
expect(
screen.getByRole("img", {
name: "Most recent commit",
}),
).toBeInTheDocument();
});

it("does not show star count and updated at when unknown", () => {
it("does not show star count when unknown", () => {
render({
repository: {
id: undefined,
Expand All @@ -312,11 +290,6 @@ describe(RepoRow.name, () => {
name: "Stars count",
}),
).not.toBeInTheDocument();
expect(
screen.queryByRole("img", {
name: "Most recent commit",
}),
).not.toBeInTheDocument();
});

it("can expand the repo item", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,55 +204,6 @@ describe(compareRepository.name, () => {
).toBeLessThan(0);
});
});

describe("when sort key is 'Most recent commit'", () => {
const sorter = compareRepository({
...permissiveFilterSortState,
sortKey: SortKey.MostRecentCommit,
});

const left = {
fullName: "github/galaxy",
updatedAt: "2020-01-01T00:00:00Z",
};
const right = {
fullName: "github/world",
updatedAt: "2021-01-01T00:00:00Z",
};

it("compares correctly", () => {
expect(sorter(left, right)).toBeGreaterThan(0);
});

it("compares the inverse correctly", () => {
expect(sorter(right, left)).toBeLessThan(0);
});

it("compares equal values correctly", () => {
expect(sorter(left, left)).toBe(0);
});

it("compares equal single values correctly", () => {
expect(
sorter(left, {
...right,
updatedAt: left.updatedAt,
}),
).toBeLessThan(0);
});

it("compares missing single values correctly", () => {
expect(
sorter(
{
...left,
updatedAt: undefined,
},
right,
),
).toBeGreaterThan(0);
});
});
});

describe(compareWithResults.name, () => {
Expand Down Expand Up @@ -303,32 +254,6 @@ describe(compareWithResults.name, () => {
});
});

describe("when sort key is 'Most recent commit'", () => {
const sorter = compareWithResults({
...permissiveFilterSortState,
sortKey: SortKey.MostRecentCommit,
});

const left = {
repository: {
id: 11,
fullName: "github/galaxy",
updatedAt: "2020-01-01T00:00:00Z",
},
};
const right = {
repository: {
id: 12,
fullName: "github/world",
updatedAt: "2021-01-01T00:00:00Z",
},
};

it("compares correctly", () => {
expect(sorter(left, right)).toBeGreaterThan(0);
});
});

describe("when sort key is results count", () => {
const sorter = compareWithResults({
...permissiveFilterSortState,
Expand Down

0 comments on commit b87fe94

Please sign in to comment.