Skip to content

Commit

Permalink
Add sorting by creation date option (#164)
Browse files Browse the repository at this point in the history
* added possibility to sort by creation date
* add accuracy to the spec time
  • Loading branch information
beliaev-maksim authored Dec 7, 2023
1 parent a55ff94 commit 30d6b17
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const Filters = ({
id="sortBy"
options={[
{ value: "date", label: "Last modified" },
{ value: "created", label: "Create date" },
{ value: "name", label: "Name" },
{ value: "index", label: "Spec index" },
]}
Expand Down
2 changes: 2 additions & 0 deletions client/UserFilterOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export function useFilteredAndSortedSpecs(specs: Spec[]) {
if (by === "date") {
key = "lastUpdated";
direction = -1;
} else if (by === "created") {
key = "created";
} else if (by === "name") {
key = "title";
} else if (by === "index") {
Expand Down
2 changes: 2 additions & 0 deletions client/tests/Filters.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ describe("renders filter component", () => {
const sortOption1 = screen.getByText("Last modified") as HTMLOptionElement;
const sortOption2 = screen.getByText("Name") as HTMLOptionElement;
const sortOption3 = screen.getByText("Spec index") as HTMLOptionElement;
const sortOption4 = screen.getByText("Create date") as HTMLOptionElement;
expect(sortOption1.selected).toBeTruthy();
expect(sortOption2.selected).toBeFalsy();
expect(sortOption3.selected).toBeFalsy();
expect(sortOption4.selected).toBeFalsy();
});

it("checks a spec status and type", () => {
Expand Down
3 changes: 2 additions & 1 deletion webapp/build_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_value_row(row, type):
if "formattedValue" in row:
return datetime.strptime(
row["formattedValue"], "%Y-%m-%dT%H:%M:%S.%fZ"
).strftime("%d %b %Y")
).strftime("%d %b %Y %H:%M")
elif "userEnteredValue" in row:
if "stringValue" in row["userEnteredValue"]:
return type(row["userEnteredValue"]["stringValue"])
Expand All @@ -20,6 +20,7 @@ def get_value_row(row, type):

return ""


def index_in_list(a_list, index):
return index < len(a_list)

Expand Down

0 comments on commit 30d6b17

Please sign in to comment.