Fix date grouping logic (#2740)

Fix timestamp grouping
This commit is contained in:
Aaron Boodman
2016-10-20 09:49:45 -07:00
committed by GitHub
parent 7099c89bc9
commit b9e104bfbd
2 changed files with 7 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ import PhotoSetIterator, {EmptyIterator} from './photo-set-iterator.js';
import Viewport from './viewport.js';
const maxPhotoHeight = 300;
const timeGroupThresholdMs = 5000;
const timeGroupThresholdNs = 5 * 1e9;
const photosPerPage = 10;
const photoSpacing = 5;
@@ -163,7 +163,7 @@ export default class PhotoGrid extends React.Component<void, Props, State> {
// Dedupe photos that were taken close together in time.
// This is a stopgap until we have proper visual deduplication.
// Note that not every photo has a taken timestamp and we always include those.
if (!taken || ((lastTaken - taken.nsSinceEpoch) > timeGroupThresholdMs)) {
if (!taken || ((lastTaken - taken.nsSinceEpoch) > timeGroupThresholdNs)) {
const hash = nomsPhoto.hash.toString();
const path = `.byDate[${negDate}][#${hash}]`;
moreP.push(createPhoto(path, nomsPhoto));

View File

@@ -57,8 +57,8 @@ const hasTitle = makeStructType('', {
title: stringStruct,
});
const hasExifTime = makeStructType('', {
gphotoQ24exiftime: makeListType(stringStruct),
const hasTimestamp = makeStructType('', {
gphotoQ24timestamp: stringStruct,
});
const hasFaces = makeStructType('', {
@@ -117,11 +117,9 @@ async function main(): Promise<void> {
photo.title = v.title.Q24t;
}
if (isSubtype(hasExifTime, v.type)) {
if (v.gphotoQ24exiftime.length === 1) {
photo.dateTaken = getDate(parseInt(
(await v.gphotoQ24exiftime.get(0)).Q24t, 10));
}
if (isSubtype(hasTimestamp, v.type)) {
photo.dateTaken = getDate(parseInt(
v.gphotoQ24timestamp.Q24t, 10));
}
if (isSubtype(hasGeo, v.type)) {