Skip to content

Commit

Permalink
filter-out non-epoch pointer files
Browse files Browse the repository at this point in the history
  • Loading branch information
nl0 committed Jan 14, 2021
1 parent c0d05cf commit c8efca3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion catalog/app/containers/Bucket/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ function Head({ req, s3, overviewUrl, bucket, description }) {
const isRODA = !!overviewUrl && overviewUrl.includes(`/${RODA_BUCKET}/`)
const colorPool = useConst(() => mkKeyedPool(COLOR_MAP))
const statsData = useData(requests.bucketStats, { req, s3, bucket, overviewUrl })
const pkgCountData = useData(requests.countPackages, { req, bucket })
const pkgCountData = useData(requests.countPackageRevisions, { req, bucket })
return (
<M.Paper className={classes.root}>
<M.Box className={classes.top}>
Expand Down
33 changes: 28 additions & 5 deletions catalog/app/containers/Bucket/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,11 @@ const mkFilterQuery = (filter) =>

export const countPackages = withErrorHandling(async ({ req, bucket, filter }) => {
const body = {
query: mkFilterQuery(filter),
query: {
bool: {
must: [mkFilterQuery(filter), { regexp: { pointer_file: TIMESTAMP_RE_SRC } }],
},
},
aggs: {
packages: {
terms: { field: 'handle' },
Expand Down Expand Up @@ -807,7 +811,11 @@ export const listPackages = withErrorHandling(
})

const body = {
query: mkFilterQuery(filter),
query: {
bool: {
must: [mkFilterQuery(filter), { regexp: { pointer_file: TIMESTAMP_RE_SRC } }],
},
},
aggs: {
packages: {
composite: {
Expand Down Expand Up @@ -913,7 +921,14 @@ export const countPackageRevisions = ({ req, bucket, name }) =>
index: `${bucket}_packages`,
action: 'packages',
body: JSON.stringify({
query: { term: { handle: name } },
query: {
bool: {
must: [
name ? { term: { handle: name } } : { match_all: {} },
{ regexp: { pointer_file: TIMESTAMP_RE_SRC } },
],
},
},
aggs: {
revisions: { sum: { script: 'doc.delete_marker.value ? -1 : 1' } },
},
Expand All @@ -940,7 +955,14 @@ export const getPackageRevisions = withErrorHandling(
size: 0,
filter_path: 'aggregations.revisions.buckets.latest.hits.hits._source',
body: JSON.stringify({
query: { term: { handle: name } },
query: {
bool: {
must: [
{ term: { handle: name } },
{ regexp: { pointer_file: TIMESTAMP_RE_SRC } },
],
},
},
aggs: {
revisions: {
composite: {
Expand Down Expand Up @@ -1008,7 +1030,8 @@ export const loadRevisionHash = ({ s3, bucket, name, id }) =>
}))

const HASH_RE = /^[a-f0-9]{64}$/
const TIMESTAMP_RE = /^1[0-9]{9}$/
const TIMESTAMP_RE_SRC = '[0-9]{10}'
const TIMESTAMP_RE = new RegExp(`^${TIMESTAMP_RE_SRC}$`)

// returns { hash, modified }
export async function resolvePackageRevision({ s3, bucket, name, revision }) {
Expand Down

0 comments on commit c8efca3

Please sign in to comment.