Skip to content

Commit

Permalink
Merge pull request #169 from amosproj/fix/#166-explorer-does-show-all…
Browse files Browse the repository at this point in the history
…-container-entries-from-the-sql-table

Fix/#166 explorer does show all container entries from the sql table
  • Loading branch information
smnws authored Jun 20, 2023
2 parents b6f82d0 + 1eb21bc commit 90ce174
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Explorer/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: "http://localhost:3000",
setupNodeEvents(/*on, config*/) {
// implement node event listeners here
},
Expand Down
2 changes: 1 addition & 1 deletion Explorer/cypress/e2e/cypress_test.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe("Navigation", () => {
it("should navigate to the about page", () => {
// Start from cypress_test_1
cy.visit("http://localhost:3001/cypress_test/cypress_test_1");
cy.visit("/cypress_test/cypress_test_1");

// Find a link with an href attribute containing "cypress_test_2" and click it
cy.get('a[href*="cypress_test_2"]').click();
Expand Down
12 changes: 11 additions & 1 deletion Explorer/src/lib/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ export async function getContainerDetails(

export async function getContainerList(): Promise<ContainerList> {
const res = await pool.query(
"SELECT * FROM containers order by timestamp DESC"
// returns entry with the last timestamp for every unique (name, pod_id)
`SELECT
*
FROM (
SELECT
*,
RANK() OVER (PARTITION BY name, pod_id ORDER BY timestamp DESC) AS rank
FROM
containers) t
WHERE
t.rank = 1`
);
const containers: ContainerData[] = res.rows;
return containers;
Expand Down

0 comments on commit 90ce174

Please sign in to comment.