Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refresh edited insights panel on change #10180

Merged
merged 4 commits into from Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions api/src/utils/get-default-index-name.ts
@@ -1,5 +1,4 @@
import { simpleHash } from './get-simple-hash';

import { getSimpleHash } from '@directus/shared/utils';
/**
* Generate an index name for a given collection + fields combination.
*
Expand All @@ -20,7 +19,7 @@ export function getDefaultIndexName(

if (indexName.length <= 60) return indexName;

const suffix = `__${simpleHash(indexName)}_${type}`;
const suffix = `__${getSimpleHash(indexName)}_${type}`;
const prefix = indexName.substring(0, 60 - suffix.length);

return `${prefix}${suffix}`;
Expand Down
14 changes: 6 additions & 8 deletions app/src/panels/time-series/time-series.vue
Expand Up @@ -8,7 +8,7 @@ import api from '@/api';
import ApexCharts from 'apexcharts';
import { adjustDate } from '@/utils/adjust-date';
import { useI18n } from 'vue-i18n';
import { isEqual, isNil } from 'lodash';
import { isNil } from 'lodash';
import { useFieldsStore } from '@/stores';
import { Filter } from '@directus/shared/types';
import { abbreviateNumber } from '@/utils/abbreviate-number';
Expand Down Expand Up @@ -111,13 +111,11 @@ export default defineComponent({
});

watch(
[() => props, () => props.showHeader, () => props.height],
(newVal, oldVal) => {
if (isEqual(newVal, oldVal) === false) {
fetchData();
chart.value?.destroy();
setupChart();
}
() => props,
() => {
fetchData();
chart.value?.destroy();
setupChart();
},
{ deep: true }
);
Expand Down
11 changes: 11 additions & 0 deletions packages/shared/src/utils/get-simple-hash.test.ts
@@ -0,0 +1,11 @@
import { getSimpleHash } from './get-simple-hash';

describe('getSimpleHash', () => {
it('returns "364492" for string "test"', () => {
expect(getSimpleHash('test')).toBe('364492');
});

it('returns "28cb67ba" for stringified object "{ key: \'value\' }"', () => {
expect(getSimpleHash(JSON.stringify({ key: 'value' }))).toBe('28cb67ba');
});
});
rijkvanzanten marked this conversation as resolved.
Show resolved Hide resolved
Expand Up @@ -2,7 +2,7 @@
* Generate a simple short hash for a given string
* This is not cryptographically secure in any way, and has a high chance of collision
*/
export function simpleHash(str: string) {
export function getSimpleHash(str: string) {
let hash = 0;

for (let i = 0; i < str.length; hash &= hash) {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/utils/index.ts
Expand Up @@ -6,6 +6,7 @@ export * from './get-collection-type';
export * from './get-fields-from-template';
export * from './get-filter-operators-for-type';
export * from './get-relation-type';
export * from './get-simple-hash';
export * from './is-dynamic-variable';
export * from './is-extension';
export * from './merge-filters';
Expand Down