<commit_before>// Copyright 2014 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package orchestrator

import (
	"github.com/andreaskoch/allmark2/common/config"
	"github.com/andreaskoch/allmark2/common/logger"
	"github.com/andreaskoch/allmark2/dataaccess"
	"github.com/andreaskoch/allmark2/services/converter"
	"github.com/andreaskoch/allmark2/services/parser"
	"github.com/andreaskoch/allmark2/web/webpaths"
)

func NewFactory(logger logger.Logger, config config.Config, repository dataaccess.Repository, parser parser.Parser, converter converter.Converter, webPathProvider webpaths.WebPathProvider) *Factory {

	baseOrchestrator := newBaseOrchestrator(logger, config, repository, parser, converter, webPathProvider)

	return &Factory{
		logger: logger,

		baseOrchestrator: baseOrchestrator,
	}
}

type Factory struct {
	logger logger.Logger

	baseOrchestrator *Orchestrator
}

func (factory *Factory) NewConversionModelOrchestrator() ConversionModelOrchestrator {
	return ConversionModelOrchestrator{
		Orchestrator:     factory.baseOrchestrator,
		fileOrchestrator: factory.NewFileOrchestrator(),
	}
}

func (factory *Factory) NewFeedOrchestrator() FeedOrchestrator {
	return FeedOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewFileOrchestrator() FileOrchestrator {
	return FileOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewNavigationOrchestrator() NavigationOrchestrator {
	return NavigationOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewOpenSearchDescriptionOrchestrator() OpenSearchDescriptionOrchestrator {
	return OpenSearchDescriptionOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewSearchOrchestrator() SearchOrchestrator {
	return SearchOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewSitemapOrchestrator() SitemapOrchestrator {
	return SitemapOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewTagsOrchestrator() TagsOrchestrator {

	return TagsOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewViewModelOrchestrator() ViewModelOrchestrator {

	orchestrator := ViewModelOrchestrator{
		Orchestrator: factory.baseOrchestrator,

		navigationOrchestrator: factory.NewNavigationOrchestrator(),
		tagOrchestrator:        factory.NewTagsOrchestrator(),
		fileOrchestrator:       factory.NewFileOrchestrator(),
		locationOrchestrator:   factory.NewLocationOrchestrator(),
	}

	// refresh control
	go func() {
		for {
			select {
			case <-orchestrator.repository.AfterReindex():
				// reset the list
				factory.logger.Info("Resetting the leafes list")
				factory.baseOrchestrator.ResetCache()
			}
		}
	}()

	return orchestrator
}
<commit_msg>Make sure the cache control is only executed once per repository.<commit_after>// Copyright 2014 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package orchestrator

import (
	"github.com/andreaskoch/allmark2/common/config"
	"github.com/andreaskoch/allmark2/common/logger"
	"github.com/andreaskoch/allmark2/dataaccess"
	"github.com/andreaskoch/allmark2/services/converter"
	"github.com/andreaskoch/allmark2/services/parser"
	"github.com/andreaskoch/allmark2/web/webpaths"
)

func NewFactory(logger logger.Logger, config config.Config, repository dataaccess.Repository, parser parser.Parser, converter converter.Converter, webPathProvider webpaths.WebPathProvider) *Factory {

	baseOrchestrator := newBaseOrchestrator(logger, config, repository, parser, converter, webPathProvider)

	// refresh control
	go func() {
		for {
			select {
			case <-repository.AfterReindex():
				// reset the list
				logger.Debug("Resetting the the cache")
				baseOrchestrator.ResetCache()
			}
		}
	}()

	return &Factory{
		logger: logger,

		baseOrchestrator: baseOrchestrator,
	}
}

type Factory struct {
	logger logger.Logger

	baseOrchestrator *Orchestrator
}

func (factory *Factory) NewConversionModelOrchestrator() ConversionModelOrchestrator {
	return ConversionModelOrchestrator{
		Orchestrator:     factory.baseOrchestrator,
		fileOrchestrator: factory.NewFileOrchestrator(),
	}
}

func (factory *Factory) NewFeedOrchestrator() FeedOrchestrator {
	return FeedOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewFileOrchestrator() FileOrchestrator {
	return FileOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewNavigationOrchestrator() NavigationOrchestrator {
	return NavigationOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewOpenSearchDescriptionOrchestrator() OpenSearchDescriptionOrchestrator {
	return OpenSearchDescriptionOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewSearchOrchestrator() SearchOrchestrator {
	return SearchOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewSitemapOrchestrator() SitemapOrchestrator {
	return SitemapOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewTagsOrchestrator() TagsOrchestrator {

	return TagsOrchestrator{
		Orchestrator: factory.baseOrchestrator,
	}
}

func (factory *Factory) NewViewModelOrchestrator() ViewModelOrchestrator {

	orchestrator := ViewModelOrchestrator{
		Orchestrator: factory.baseOrchestrator,

		navigationOrchestrator: factory.NewNavigationOrchestrator(),
		tagOrchestrator:        factory.NewTagsOrchestrator(),
		fileOrchestrator:       factory.NewFileOrchestrator(),
		locationOrchestrator:   factory.NewLocationOrchestrator(),
	}

	return orchestrator
}

{'fraction_non_alphanumeric': 0.0883054892601432, 'fraction_numerical': 0.0034094783498124785, 'mean_word_length': 5.814169570267131, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1434896', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1912, 'n_words': 366}