From 97130ffd741fb967f00c0e76672348a3925d6940 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 13 Jun 2016 19:54:32 +0100 Subject: Dedupe the change log file list --- gentoobrowse-api/service/maintenanceChangeLogs.cpp | 3 +++ gentoobrowse-api/unittests/testChangeLog.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/gentoobrowse-api/service/maintenanceChangeLogs.cpp b/gentoobrowse-api/service/maintenanceChangeLogs.cpp index 46ef3e2..027429e 100644 --- a/gentoobrowse-api/service/maintenanceChangeLogs.cpp +++ b/gentoobrowse-api/service/maintenanceChangeLogs.cpp @@ -104,6 +104,9 @@ namespace Gentoo { // Compare trees StringList fs; git_diff_foreach(diff.get(), onFile, onBinaryFile, nullptr, nullptr, &fs); + // Remove duplicate mentions of files + std::sort(fs.begin(), fs.end()); + fs.erase(std::unique(fs.begin(), fs.end()), fs.end()); // Insert commit into DB cli->bindParamS(1, str); diff --git a/gentoobrowse-api/unittests/testChangeLog.cpp b/gentoobrowse-api/unittests/testChangeLog.cpp index 412b328..df01a7b 100644 --- a/gentoobrowse-api/unittests/testChangeLog.cpp +++ b/gentoobrowse-api/unittests/testChangeLog.cpp @@ -22,9 +22,11 @@ BOOST_AUTO_TEST_CASE( importChangeLogs ) insRepo->execute(); const int64_t expectedLogCount = 125; + const int64_t expectedFilesCount = 9; m->refreshChangeLogs(); SQL_REQUIRE_EQUAL("SELECT COUNT(*) FROM gentoobrowse.changelog", int64_t, expectedLogCount); + SQL_REQUIRE_EQUAL("SELECT ARRAY_LENGTH(files, 1) FROM gentoobrowse.changelog WHERE commitid = 'f8e9b2f0044232213a6e0299a3f31752e8dd9d24'", int64_t, expectedFilesCount); db->execute("COPY gentoobrowse.changelog TO '/tmp/changelog.tsv'"); } -- cgit v1.2.3