package NWebmaster.proto.digest;


message IndicatorDouble {
    required double old_value       = 1;
    required double new_value       = 2;
    required double diff            = 3;
    required double diff_percent    = 4;
}

message IndicatorLong {
    required int64 old_value        = 1;
    required int64 new_value        = 2;
    required int64 diff             = 3;
    required double diff_percent    = 4;
}

message ClicksByPeriod {
    required int64 clicks       = 1;
    required int64 timestamp    = 2;
}

message AllQueriesIndicators {
    optional IndicatorDouble position               = 1;
    optional IndicatorLong clicks                   = 2;
    optional IndicatorLong shows                    = 3;
    repeated ClicksByPeriod old_clicks_by_period    = 4;
    repeated ClicksByPeriod new_clicks_by_period    = 5;
}

message QueryPositionSample {
    required string query               = 1;
    required IndicatorDouble position   = 2;
}

message QueryShowsSample {
    required string query           = 1;
    required IndicatorLong shows    = 2;
}

message QueryClicksSample {
    required string query           = 1;
    required IndicatorLong clicks   = 2;
}

message GroupPositionSample {
    optional string group_id            = 1;
    optional string group_name          = 2;
    required IndicatorDouble position   = 3;
}

message GroupShowsSample {
    optional string group_id         = 1;
    optional string group_name       = 2;
    required IndicatorLong shows     = 3;
}

message GroupClicksSample {
    optional string group_id         = 1;
    optional string group_name       = 2;
    required IndicatorLong clicks    = 3;
}

message AllFavoriteQuerySamples {
    optional IndicatorDouble position   = 1;
    optional IndicatorLong clicks       = 2;
    optional IndicatorLong shows        = 3;
}

message GroupQuerySamples {
    repeated GroupClicksSample positive_query_clicks_samples        = 1;
    repeated GroupClicksSample negative_query_clicks_samples        = 2;
    repeated GroupShowsSample positive_query_shows_samples          = 3;
    repeated GroupShowsSample negative_query_shows_samples          = 4;
    repeated GroupPositionSample positive_query_position_samples    = 5;
    repeated GroupPositionSample negative_query_position_samples    = 6;
}

message SplitFavoriteQuerySamples {
    repeated QueryClicksSample positive_query_clicks_samples        = 1;
    repeated QueryClicksSample negative_query_clicks_samples        = 2;
    repeated QueryShowsSample positive_query_shows_samples          = 3;
    repeated QueryShowsSample negative_query_shows_samples          = 4;
    repeated QueryPositionSample positive_query_position_samples    = 5;
    repeated QueryPositionSample negative_query_position_samples    = 6;
}

message TopQuerySamples {
    repeated QueryClicksSample positive_query_clicks_samples        = 1;
    repeated QueryClicksSample negative_query_clicks_samples        = 2;
    repeated QueryShowsSample positive_query_shows_samples          = 3;
    repeated QueryShowsSample negative_query_shows_samples          = 4;
    repeated QueryPositionSample positive_query_position_samples    = 5;
    repeated QueryPositionSample negative_query_position_samples    = 6;
}

message GeoRegionInfo {
    required int64 region_id    = 1;
    required int64 source_id    = 2;
}

message GeoWeekState {
    required bool visible           = 1;
    optional string error           = 2;
    repeated GeoRegionInfo regions  = 3;
}

message GeoState {
    optional GeoWeekState old_state             = 1;
    optional GeoWeekState new_state             = 2;
    repeated GeoRegionInfo regions_gone         = 3;
    repeated GeoRegionInfo regions_new          = 4;
    repeated GeoRegionInfo regions_unchanged    = 5;
}

message BeautyUrlState {
    required string old_state   = 1;
    required string new_state   = 2;
}

enum ImportantUrlEventType {
    EVENT_ADDED_TO_SEARCH       = 0;
    EVENT_REMOVED_FROM_SEARCH   = 1;
    EVENT_HTTP_CODE_CHANGED     = 2;
}

message ImportantUrlState {
    optional string path        = 1;
    optional int64 url_status   = 2;
    optional string title       = 3;
    optional bool is_searchable = 4;
    optional int64 http_code    = 5;
}

message ImportantUrlEvent {
    required string path                        = 1;
    required ImportantUrlState old_state        = 2;
    required ImportantUrlState new_state        = 3;
    required ImportantUrlEventType event_type   = 4;
    optional string old_string                  = 5;
    optional string new_string                  = 6;
    optional int64 old_int                      = 7;
    optional int64 new_int                      = 8;
}

message ImportantUrls {
    repeated ImportantUrlEvent events       = 1;
    repeated ImportantUrlState added_urls   = 2;
    repeated ImportantUrlState removed_urls = 3;
    optional int64 old_count                = 4;
    optional int64 new_count                = 5;
}

message RecommendedUrlState {
    optional string path    = 1;
    optional int64 clicks   = 2;
    optional int64 shows    = 3;
}

message RecommendedUrls {
    repeated RecommendedUrlState recommended_urls = 3;
}

message SitetreeState {
    optional int64 num_of_docs              = 1;
    optional int64 num_of_docs_on_search    = 2;
    optional int64 new_docs_on_search       = 3;
    optional int64 gone_docs_on_search      = 4;
}

message SitetreeUrlHistory {
    optional string path        = 1;
    optional int64 url_status   = 2;
    optional bool is_added      = 3; 
    optional string title       = 4;
}

message Sitetree {
    optional SitetreeState old_state        = 1;
    optional SitetreeState new_state        = 2;
    repeated SitetreeUrlHistory url_history = 3;
}

message RecrawlUrlState {
    required string path        = 1;
    required int32 http_code    = 2;
    optional bool success       = 3;
    optional int64 timestamp    = 4;
}

message RecrawlUrls {
    repeated RecrawlUrlState new_state   = 1;
}

message CheckListStatus {
    repeated int32 problems = 1;
}

message CheckList {
    optional CheckListStatus old_status = 1;
    optional CheckListStatus new_status = 2;
}

message UserVerificationState {
    optional int64 user_id  = 1;
    optional string login   = 2;
    optional string type    = 3;
    optional int64 time     = 4;
}

message UserVerifications {
    repeated UserVerificationState new_verifications    = 1;
}

message IKSState {
    optional uint64 iks         = 1;
    optional int64 timestamp    = 2;
}

message IKS {
    optional IKSState old_state = 1;
    optional IKSState new_state = 2;
    required string owner       = 3;
}

message Reviews {
    optional uint64 count_new       = 1;
    optional uint64 count_old       = 2;
}

message AchievementsSnapshot {
	optional string brands 					= 1;
	optional bool https 			        = 2;
	optional bool official					= 3;
	optional string official_auto			= 4;
	optional bool official_avia				= 5;
	optional bool official_cbr				= 6;
	optional bool official_embassy			= 7;
	optional bool official_mfo				= 8;
	optional bool official_ssd				= 9;
	optional bool official_visa				= 10;
	optional bool official_visa_center		= 11;
	optional int32 popular					= 12;
	optional string service_center			= 13;
	optional bool ssl_broken				= 14;
	optional bool tasix						= 15;
	optional int32 user_selection			= 16;
	optional bool speed_desktop				= 17;
	optional uint32 absolute_speed_desktop	= 18;
	optional bool speed_mobile				= 19;
    optional uint32 absolute_speed_mobile	= 20;
    required string tld						= 21;
    optional bool turbo				        = 22;
    optional uint32 docs_on_search	        = 23;
    optional uint32 speed_grade_mobile		= 24;
    optional bool official_yandex			= 25;

}

message SrcAchievements{
    repeated AchievementsSnapshot achievements  = 1;
}

message Achievements {
    repeated AchievementsSnapshot achievements_old 	= 1;
    repeated AchievementsSnapshot achievements_new 	= 2;
}

message Mirrors {
    optional string main_mirror 	= 1;
}

message DigestWeeklyReportMessage {
    optional AllFavoriteQuerySamples all_favorite_queries       = 1;
    optional AllQueriesIndicators all_queries                   = 2;
    optional GroupQuerySamples group_queries                    = 3;
    optional SplitFavoriteQuerySamples split_favorite_queries   = 4;
    optional TopQuerySamples top_queries                        = 5;
    optional GeoState geo_regions                               = 6;
    optional BeautyUrlState beauty_urls                         = 7;
    optional ImportantUrls important_urls                       = 8;
    optional Sitetree sitetrees                                 = 9;
    optional RecrawlUrls recrawl_urls                           = 10;
    optional RecommendedUrls recommended_urls                   = 11;
    optional CheckList checklist                                = 12;
    optional UserVerifications user_verifications               = 13;
    optional IKS iks                                            = 14;
	optional Achievements achievements							= 15;
	optional Reviews reviews							        = 16;
	optional Mirrors mirrors							        = 17;
}
